[projects/git-slug: 66/170] Read old version of head file from git repository
glen
glen at pld-linux.org
Mon Sep 21 21:44:21 CEST 2015
commit febb8f11899319561cac1e1b721043f34d740546
Author: Kacper Kornet <draenog at pld-linux.org>
Date: Tue Dec 13 16:29:13 2011 +0100
Read old version of head file from git repository
slug_watch | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/slug_watch b/slug_watch
index d4f402e..fba3e1a 100755
--- a/slug_watch
+++ b/slug_watch
@@ -3,7 +3,6 @@
import heapq
import os
import pyinotify
-import shutil
from git_slug.gitconst import EMPTYSHA1, REFREPO, REFFILE
from git_slug.serverconst import WATCHDIR
@@ -23,7 +22,7 @@ mask = pyinotify.IN_CLOSE_WRITE # watched events
def convertstream(stream):
for line in stream:
- (sha1, ref, repo) = line.split()
+ (sha1, ref, repo) = line.decode('utf-8').split()
yield (repo, ref, 1, sha1)
def processnewfile(stream):
@@ -38,16 +37,17 @@ def process_file(pathname):
if not os.path.isfile(pathname):
print('{} is not an ordinary file'.format(pathname))
return
- with open(os.path.join(REFREPO_WDIR, REFFILE),'r') as headfile, open(os.path.join(REFREPO_WDIR, REFFILE_NEW),'w') as headfile_new, open(pathname, 'r') as newfile:
+ with open(os.path.join(REFREPO_WDIR, REFFILE),'w') as headfile_new, open(pathname, 'r') as newfile:
committer = newfile.readline().strip()
oldtuple = None
+ refrepo = GitRepo(git_dir=REFREPO_GDIR)
+ headfile = refrepo.showfile(REFFILE, 'master').stdout
for (repo, ref, number, sha1) in heapq.merge(sorted(processnewfile(newfile)), convertstream(headfile)):
if (repo, ref) == oldtuple:
continue
oldtuple = (repo, ref)
if sha1 != EMPTYSHA1:
print(sha1, ref, repo, file=headfile_new)
- shutil.copyfile(os.path.join(REFREPO_WDIR, REFFILE_NEW), os.path.join(REFREPO_WDIR, REFFILE))
headrepo = GitRepo(REFREPO_WDIR, REFREPO_GDIR)
headrepo.commitfile(REFFILE, 'Changes by {}'.format(committer))
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5
More information about the pld-cvs-commit
mailing list