Skip to content

Commit c75efa5

Browse files
committed
[py3-compat] Use PyGIT.Storage.repo_path instead of shelling out to git
1 parent bd8fd09 commit c75efa5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

tracext/github/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,11 @@ def process_request(self, req):
951951
output = u'Running hook on %s\n' % (reponame or '(default)')
952952

953953
output += u'* Updating clone\n'
954-
try:
955-
git = repos.git.repo # GitRepository
956-
except AttributeError:
957-
git = repos.repos.git.repo # GitCachedRepository
958-
git.remote('update', '--prune')
954+
try: # GitRepository
955+
storage = repos.git
956+
except AttributeError: # GitCachedRepository
957+
storage = repos.repos.git
958+
storage.repo.remote('update', '--prune')
959959

960960
# Ensure that repos.get_changeset can find the new changesets.
961961
output += u'* Synchronizing with clone\n'
@@ -988,12 +988,11 @@ def process_request(self, req):
988988

989989
status = 200
990990

991-
git_dir = git.rev_parse('--git-dir').rstrip('\n')
992-
hook = os.path.join(git_dir, 'hooks', 'trac-github-update')
991+
hook = os.path.join(storage.repo_path, 'hooks', 'trac-github-update')
993992
if os.path.isfile(hook):
994993
output += u'* Running trac-github-update hook\n'
995994
try:
996-
p = Popen(hook, cwd=git_dir,
995+
p = Popen(hook, cwd=storage.repo_path,
997996
stdin=PIPE, stdout=PIPE, stderr=STDOUT,
998997
close_fds=trac.util.compat.close_fds)
999998
except Exception as e:

0 commit comments

Comments
 (0)