Added the post-update hook at the creation of the git repository.
This commit is contained in:
parent
e5ee6d8fca
commit
bbc29c889f
@ -12,11 +12,13 @@
|
|||||||
# to enable it later, you need to symlink it as "post-update" in your
|
# to enable it later, you need to symlink it as "post-update" in your
|
||||||
# $GIT_DIR/hooks folder.
|
# $GIT_DIR/hooks folder.
|
||||||
#
|
#
|
||||||
|
# www$ chmod +x /home/www/indefero/scripts/git-post-update
|
||||||
# git$ cd /home/git/repositories/project.git/hooks
|
# git$ cd /home/git/repositories/project.git/hooks
|
||||||
# git$ ln -s /home/www/indefero/scripts/git-post-update post-update
|
# git$ ln -s /home/www/indefero/scripts/git-post-update post-update
|
||||||
#
|
#
|
||||||
|
|
||||||
SCRIPTDIR=$(dirname $(readlink -f $0))
|
SCRIPTDIR=$(dirname $(readlink -f $0))
|
||||||
|
FULL_GIT_DIR=$(readlink -f $GIT_DIR)
|
||||||
PHP_POST_UPDATE=$SCRIPTDIR/gitpostupdate.php
|
PHP_POST_UPDATE=$SCRIPTDIR/gitpostupdate.php
|
||||||
|
|
||||||
echo php $PHP_POST_UPDATE $GIT_DIR | at now
|
echo php $PHP_POST_UPDATE $FULL_GIT_DIR | at now > /dev/null 2>&1
|
||||||
|
@ -66,7 +66,7 @@ class IDF_Plugin_SyncGit
|
|||||||
{
|
{
|
||||||
// Find the corresponding project.
|
// Find the corresponding project.
|
||||||
$git_dir = substr($params['git_dir'], 0, -4); // Chop the ".git"
|
$git_dir = substr($params['git_dir'], 0, -4); // Chop the ".git"
|
||||||
$elts = explode('#/#', $git_dir, -1, PREG_SPLIT_NO_EMPTY);
|
$elts = preg_split('#/#', $git_dir, -1, PREG_SPLIT_NO_EMPTY);
|
||||||
$pname = array_pop($elts);
|
$pname = array_pop($elts);
|
||||||
try {
|
try {
|
||||||
$project = IDF_Project::getOr404($pname);
|
$project = IDF_Project::getOr404($pname);
|
||||||
|
@ -203,7 +203,29 @@ class IDF_Plugin_SyncGit_Serve
|
|||||||
Pluf_Log::error(array('IDF_Plugin_Git_Serve::initRepository', $res, $fullpath));
|
Pluf_Log::error(array('IDF_Plugin_Git_Serve::initRepository', $res, $fullpath));
|
||||||
throw new Exception(sprintf('Init repository error, exit status %d.', $res));
|
throw new Exception(sprintf('Init repository error, exit status %d.', $res));
|
||||||
}
|
}
|
||||||
Pluf_Log::info(array('IDF_Plugin_Git_Serve::initRepository', 'success', $fullpath));
|
Pluf_Log::event(array('IDF_Plugin_Git_Serve::initRepository', 'success', $fullpath));
|
||||||
|
// Add the post-update hook by removing the original one and add the
|
||||||
|
// Indefero's one.
|
||||||
|
$p = realpath(dirname(__FILE__).'/../../../../scripts/git-post-update');
|
||||||
|
$p = Pluf::f('idf_plugin_syncgit_post_update', $p);
|
||||||
|
if (!@unlink($fullpath.'/hooks/post-update')) {
|
||||||
|
Pluf_Log::warn(array('IDF_Plugin_Git_Serve::initRepository',
|
||||||
|
'post-update hook removal error.',
|
||||||
|
$fullpath.'/hooks/post-update'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
exec(sprintf(Pluf::f('idf_exec_cmd_prefix', '').'ln -s %s %s',
|
||||||
|
escapeshellarg($p),
|
||||||
|
escapeshellarg($fullpath.'/hooks/post-update')),
|
||||||
|
$out, $res);
|
||||||
|
if ($res != 0) {
|
||||||
|
Pluf_Log::warn(array('IDF_Plugin_Git_Serve::initRepository',
|
||||||
|
'post-update hook creation error.',
|
||||||
|
$fullpath.'/hooks/post-update'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pluf_Log::debug(array('IDF_Plugin_Git_Serve::initRepository',
|
||||||
|
'Added post-update hook.', $fullpath));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,11 +393,11 @@ class IDF_Scm
|
|||||||
* Sync the changes in the repository with the timeline.
|
* Sync the changes in the repository with the timeline.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function syncTimeline($project)
|
public static function syncTimeline($project, $force=false)
|
||||||
{
|
{
|
||||||
$cache = Pluf_Cache::factory();
|
$cache = Pluf_Cache::factory();
|
||||||
$key = 'IDF_Scm:'.$project->shortname.':lastsync';
|
$key = 'IDF_Scm:'.$project->shortname.':lastsync';
|
||||||
if (null === ($res=$cache->get($key))) {
|
if ($force or null === ($res=$cache->get($key))) {
|
||||||
$scm = IDF_Scm::get($project);
|
$scm = IDF_Scm::get($project);
|
||||||
if ($scm->isAvailable()) {
|
if ($scm->isAvailable()) {
|
||||||
foreach ($scm->getChangeLog($scm->getMainBranch(), 25) as $change) {
|
foreach ($scm->getChangeLog($scm->getMainBranch(), 25) as $change) {
|
||||||
|
Loading…
Reference in New Issue
Block a user