xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
<root> / inc / api.inc.php (60fac49e1b4550453b1073f23827a5b2706efc2d) (1,422B) (mode 100644) [raw]
<?php
require_once($INC . "/util.inc.php");
require_once($INC . "/log.inc.php");
require_once($INC . "/sql.inc.php");
require_once($INC . "/user.inc.php");
require_once($INC . "/repo.inc.php");
require_once($INC . "/bug.inc.php");
require_once($INC . "/keys.inc.php");
require_once($INC . "/prof.inc.php");
require_once($INC . "/watch.inc.php");

/*
 * Main entry point
 */
function rg_api($db, &$a, $json)
{
	rg_prof_start('api');
	rg_log_enter('api: json=' . rg_array2string($json));

	$ret = array();
	while (1) {
		if (!isset($json['cmd'])) {
			$ret['error'] = '\'cmd\' parameter not present';
			break;
		}

		$ret['cmd'] = $json['cmd'];

		if (isset($json['opaque']))
			$ret['opaque'] = $json['opaque'];

		// Needed for logging
		rg_stats_conns_set('cmd', $json['cmd']);

		if (isset($json['user'])) {
			$a['target_ui'] = rg_user_info($db, 0, $json['user'], '');
		} else if (isset($json['uid'])) {
			$a['target_ui'] = rg_user_info($db, $json['uid'], '', '');
		} else {
			$a['target_ui'] = $a['login_ui'];
		}

		rg_stats_conns_set('uid', $a['target_ui']['uid']);

		if (strncmp($json['cmd'], 'user', 4) == 0) {
			$ret = array_merge($ret, rg_user_api($db, $a, $json));
			break;
		}

		if (strncmp($json['cmd'], 'repo', 4) == 0) {
			$ret = array_merge($ret, rg_repo_api($db, $a, $json));
			break;
		}

		$ret['error'] = 'invalid command';
		break;
	}

	rg_log_exit();
	rg_prof_end('api');
	return $ret;
}

Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master