[geany/infrastructure] a6ac4e: On GIT mirror respository update, write an agefile for CGit

Enrico Tröger git-noreply at xxxxx
Sun Apr 6 08:30:14 UTC 2014


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sun, 06 Apr 2014 08:30:14 UTC
Commit:      a6ac4e6a151c82425419c6728f2a52d0f39a1e60
             https://github.com/geany/infrastructure/commit/a6ac4e6a151c82425419c6728f2a52d0f39a1e60

Log Message:
-----------
On GIT mirror respository update, write an agefile for CGit

CGit (the web interface for Geany's GIT mirror repositories) can be fed with an
agefile to tell it the time of the last commit.
To not clutter the repositories too much, we introduce a new sub directory _geany.


Modified Paths:
--------------
    scripts/git_hooks/geany_commit_utils.py
    scripts/git_hooks/post_commit_hook.py
    scripts/git_hooks/update_repositories.py

Modified: scripts/git_hooks/geany_commit_utils.py
10 files changed, 9 insertions(+), 1 deletions(-)
===================================================================
@@ -26,7 +26,7 @@ def setup_file_logging(name, logfile):
 
 
 #----------------------------------------------------------------------
-def run_command(repository_path, command, run_as=None, logger=None):
+def run_command(repository_path, command, redirect_stdout=None, run_as=None, logger=None):
     if run_as:
         command = ('sudo', '-u', run_as) + command
     process = Popen(command, cwd=repository_path, stdout=PIPE, stderr=PIPE)
@@ -34,6 +34,10 @@ def run_command(repository_path, command, run_as=None, logger=None):
     output = u''
     if stdout:
         output = u'%s\nStdout:\n%s' % (output, stdout)
+        if redirect_stdout:
+            target_file = open(redirect_stdout, 'w')
+            target_file.write(stdout)
+            target_file.close()
     if stderr:
         output = u'%s\nStderr:\n%s' % (output, stderr)
     if logger:
@@ -45,3 +49,7 @@ def update_repository(repository, repository_path, logger, run_as=None):
     logger.info(u'Updating repository %s' % repository)
     run_command(repository_path, ('git', 'remote', 'update'), run_as=run_as, logger=logger)
     run_command(repository_path, ('git', 'update-server-info'), run_as=run_as, logger=logger)
+    run_command(repository_path,
+                ('git', 'log', '--max-count=1', '--format="%cd"', '--date=local'),
+                redirect_stdout='%s/_geany/cgit_age' % repository_path,
+                logger=logger)


Modified: scripts/git_hooks/post_commit_hook.py
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -26,8 +26,8 @@
 LOG_FILENAME = u'/var/log/git_mirror.log'
 VALID_UPDATE_REPOSITORIES = ('geany', 'geany-plugins', 'infrastructure', 'newsletter', 'talks', 'geany-themes')
 REPOSITORY_BASE_PATH = u'/srv/www/git.geany.org/repos/%s.git'
-UPDATE_LOCK_FILE = u'%s/.update_lock'
-UPDATE_NOTIFY_FILE = u'%s/.update_required'
+UPDATE_LOCK_FILE = u'%s/_geany/.update_lock'
+UPDATE_NOTIFY_FILE = u'%s/_geany/.update_required'
 # extend on demand
 LOG_EMAIL_ADDRESSES = ['enrico at geany.org']
 


Modified: scripts/git_hooks/update_repositories.py
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -20,8 +20,8 @@
 
 LOG_FILENAME = u'/var/log/git_mirror.log'
 REPOSITORY_BASE_PATH = u'/srv/www/git.geany.org/repos/'
-UPDATE_LOCK_FILE = u'%s/.update_lock'
-UPDATE_NOTIFY_FILE = u'%s/.update_required'
+UPDATE_LOCK_FILE = u'%s/_geany/.update_lock'
+UPDATE_NOTIFY_FILE = u'%s/_geany/.update_required'
 
 
 #----------------------------------------------------------------------



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list