[projects/git-slug: 1/9] check_remote(): Add support to packed refs database.
glen
glen at pld-linux.org
Mon Sep 21 21:40:47 CEST 2015
commit fac30722a98a4d6300822fd3f790ce1fa48e7d83
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sun Nov 23 00:15:10 2014 +0100
check_remote(): Add support to packed refs database.
check_remote() did not handle git packed refs database. That made
fetch_packages() to always fetch packages even if we already had
them fetched.
Supporting packed refs database fixes this problem.
git_slug/gitrepo.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/git_slug/gitrepo.py b/git_slug/gitrepo.py
index 5234deb..d9f88ee 100644
--- a/git_slug/gitrepo.py
+++ b/git_slug/gitrepo.py
@@ -82,12 +82,21 @@ class GitRepo:
'refs/notes/*:refs/notes/*'])
def check_remote(self, ref, remote=REMOTE_NAME):
+ localref = EMPTYSHA1
ref = ref.replace(REFFILE, os.path.join('remotes', remote))
try:
with open(os.path.join(self.gdir, ref), 'r') as f:
localref = f.readline().strip()
except IOError:
- localref = EMPTYSHA1
+ try:
+ with open(os.path.join(self.gdir, 'packed-refs')) as f:
+ for line in f:
+ line_data = line.split()
+ if len(line_data) == 2 and line_data[1] == ref:
+ localref = line_data[0].strip()
+ break
+ except IOError:
+ pass
return localref
def showfile(self, filename, ref="/".join([REMOTE_NAME, "master"])):
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/d9fdf7d60e5aea39f9ac7065a09a645261fc712b
More information about the pld-cvs-commit
mailing list