Browse Source

Changed to have an always-made local repo and just update it as needed

pull/24/head
Teknikode 8 years ago
parent
commit
0c3bcbfedb
  1. 20
      includes/update_profile.php

20
includes/update_profile.php

@ -131,17 +131,14 @@ if(isset($_POST)) @@ -131,17 +131,14 @@ if(isset($_POST))
// Add the user's keys to his git account
if ($public_key != $user->public_key)
{
if (!is_dir('../cache/gitolite-admin'))
{
mkdir('../cache/gitolite-admin', 0777, true);
}
$Git = new Git();
$Git->windows_mode();
$repo = $Git->clone_remote('/cygdrive/c/inetpub/wwwroot/teknik/cache/gitolite-admin/', 'git@localhost:gitolite-admin');
$repo = $Git->open($CONF['git_repo_path']."gitolite-admin\\");
$repo->pull('origin', 'master');
if (is_dir("../cache/gitolite-admin/keydir/u/".$user->username))
if (is_dir($CONF['git_repo_path']."gitolite-admin\\keydir\\u\\".$user->username))
{
$files = glob("../cache/gitolite-admin/keydir/u/".$user->username."/*");
$files = glob($CONF['git_repo_path']."gitolite-admin\\keydir\\u\\".$user->username."/*");
foreach($files as $file){ // iterate files
if(is_file($file))
unlink($file); // delete file
@ -149,7 +146,7 @@ if(isset($_POST)) @@ -149,7 +146,7 @@ if(isset($_POST))
}
else
{
mkdir("../cache/gitolite-admin/keydir/u/".$user->username, 0777, true);
mkdir($CONF['git_repo_path']."gitolite-admin\\keydir\\u\\".$user->username, 0777, true);
}
$index = 0;
$keys = explode(",", $public_key);
@ -158,7 +155,7 @@ if(isset($_POST)) @@ -158,7 +155,7 @@ if(isset($_POST))
preg_match($pattern, $key, $matches);
$key = "ssh-rsa " . $matches[2];
$keyFileName = "../cache/gitolite-admin/keydir/u/".$user->username."/".$user->username."@Key".$index.".pub";
$keyFileName = $CONF['git_repo_path']."gitolite-admin\\keydir\\u\\".$user->username."\\".$user->username."@Key".$index.".pub";
$fileHandle = fopen($keyFileName, 'w');
fwrite($fileHandle, $key);
fclose($fileHandle);
@ -167,11 +164,6 @@ if(isset($_POST)) @@ -167,11 +164,6 @@ if(isset($_POST))
$repo->add('.');
$repo->commit('Modified keys for '.$user->username);
$repo->push('origin', 'master');
if (is_dir('../cache/gitolite-admin'))
{
unlink('../cache/gitolite-admin');
}
}
/*
if ($minecraft != $user->minecraft_user)

Loading…
Cancel
Save