#!/usr/bin/php
<?php
// This is called by 'pre-commit' hook
// Inspired by pre-commit.sample in git package
error_reporting(E_ALL);
ini_set("track_errors", "On");
$_start = microtime(TRUE);
require_once("/etc/rg/config.php");
$INC = dirname(__FILE__) . "/../inc";
require_once($INC . "/util.inc.php");
require_once($INC . "/log.inc.php");
require_once($INC . "/db.inc.php");
require_once($INC . "/repo.inc.php");
rg_log_set_file("/tmp/rg_hook_pre-commit.log");
rg_log("Start: euid=" . posix_geteuid() . "...");
rg_log("_SERVER: " . print_r($_SERVER, TRUE));
umask(0022);
$against =
if (rg_git_ref_ok("HEAD"))
$against = "HEAD";
else
$against = $rg_repo_empty;
// TODO: Here we can deny non ascii file names
// git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0')
$diff = sprintf("%u", (microtime(TRUE) - $_start) * 1000);
rg_log("Took " . $diff . "ms.");
@file_put_contents($repo_path . "/rg/hook-pre-commit",
"repo: " . $repo . " ($repo_path)"
. "\nat: " . sprintf("%u", $_start)
. "\nuid: " . $uid
. "\ncmd: against=$against"
. "\nTook: " . $diff . "ms");
// Mark repository dirty for disk statistics and other stuff
@file_put_contents($rg_path . "/dirty", "");
?>
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