[projects/git-slug: 168/170] slug_watch: Add projects.list.head file feature
glen
glen at pld-linux.org
Mon Sep 21 21:52:56 CEST 2015
commit 8477bfef0040fc347ea5cc18988fcc9957527887
Author: Kacper Kornet <draenog at pld-linux.org>
Date: Tue Mar 26 12:40:03 2013 +0000
slug_watch: Add projects.list.head file feature
The adminitrator can create projects.list.head file. Its contents
will be added at the beginning of projects.list file.
slug_watch | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/slug_watch b/slug_watch
index 2a0da28..7b64460 100755
--- a/slug_watch
+++ b/slug_watch
@@ -8,6 +8,7 @@ import logging.handlers
import os
import pwd
import pyinotify
+import shutil
import signal
import sys
@@ -21,6 +22,7 @@ from git_slug.gitrepo import GitRepo
LOCKFILE = 'slug_watch.lock'
PROJECTS_LIST = 'projects.list'
PROJECTS_LIST_NEW = PROJECTS_LIST + '.new'
+PROJECTS_LIST_HEAD = PROJECTS_LIST + '.head'
REFFILE_NEW = REFFILE + '.new'
REFREPO_WDIR = 'Refs'
@@ -60,8 +62,14 @@ def process_file(pathname):
if not os.path.isfile(pathname):
print('{} is not an ordinary file'.format(pathname))
return
+
+ try:
+ shutil.copyfile(PROJECTS_LIST_HEAD, PROJECTS_LIST_NEW)
+ except (OSError, shutil.Error):
+ logger.error('Cannot write {}'.format(PROJECTS_LIST_NEW))
+
with open(os.path.join(REFREPO_WDIR, REFFILE),'w') as headfile_new, open(pathname, 'r') as newfile, \
- open(PROJECTS_LIST_NEW,'w') as projects:
+ open(PROJECTS_LIST_NEW,'a') as projects:
committer = newfile.readline().strip()
oldtuple = (None, None)
refrepo = GitRepo(git_dir=REFREPO_GDIR)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5
More information about the pld-cvs-commit
mailing list