Main »

Talk: GitCommit

This is the talk page for discussing the Main.GitCommit article.


<?php if (!defined('PmWiki')) exit();

// VERSION INFO
$RecipeInfo['GitCommit']['Version'] = '2017-11-09';

// For (:if enabled GitCommit:)
global $GitCommit; $GitCommit = 1;

# add "?action=git-commit"
SDV($HandleActions['git-commit'], 'HandleGitCommit');
SDV($HandleAuth['git-commit'], 'admin');

function HandleGitCommit($pagename, $auth) {
	$page = RetrieveAuthPage($pagename,$auth,true,READPAGE_CURRENT);
	if(!$page) exit();

	$message = "manual backup";

	## Commented for now, because if we don't cd, and just run in the default 
	## dir, that'll automatically go up the tree to the root of the current 
	## wiki, which is what we want anyway.
	# $repo_dir = "wiki.obormot.net";

	ob_start();
	# echo `cd /home/public/{$repo_dir} 2>&1`;
	# echo "{$repo_dir}\n";
	echo `pwd 2>&1`;
	echo `date 2>&1`;
	echo `git add . 2>&1`;
	echo `git commit -uno -m '{$message}' 2>&1`;
	echo `git update-server-info 2>&1`;
	$out = ob_get_contents();
	ob_end_clean();

	global $MessagesFmt;
	$MessagesFmt[] = "<div class='wikimessage'>\n";
	$MessagesFmt[] = "<h3 style='margin-bottom: 0.5em; '>Output:</h3>\n";
	$MessagesFmt[] = "<pre>{$out}</pre>\n";
	$MessagesFmt[] = "</div>\n";

	HandleBrowse($pagename, $auth);
}