git/hooks: Start making the hooks crash less on rhel8/python3
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
adce324050
commit
6e82268613
3 changed files with 13 additions and 6 deletions
|
@ -57,6 +57,7 @@ def read_output(cmd, abspath, input=None, keepends=False, **kw):
|
|||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
cwd=abspath,
|
||||
universal_newlines=True,
|
||||
**kw)
|
||||
(out, err) = procs.communicate(input)
|
||||
retcode = procs.wait()
|
||||
|
@ -66,7 +67,7 @@ def read_output(cmd, abspath, input=None, keepends=False, **kw):
|
|||
print(err)
|
||||
if not keepends:
|
||||
out = out.rstrip('\n\r')
|
||||
return unicode(out, errors='ignore')
|
||||
return out
|
||||
|
||||
|
||||
def read_git_output(args, abspath, input=None, keepends=False, **kw):
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
pee \
|
||||
/usr/share/git-core/post-receive-fedora-messaging \
|
||||
/usr/share/git-core/post-receive-alternativearch \
|
||||
/usr/lib/python2.7/site-packages/pagure/hooks/files/post-receive \
|
||||
/usr/lib/python3.6/site-packages/pagure/hooks/files/post-receive \
|
||||
"/usr/bin/grok-manifest -m /srv/git/grokmirror/manifest.js.gz -t /srv/git/repositories/ -n `pwd`"
|
||||
|
||||
# We used to send emails directly from the git hook here, but now we send to
|
||||
|
|
|
@ -40,7 +40,13 @@ def revs_between(head, base):
|
|||
|
||||
# pygit2 can't do a rev-list yet, so we have to shell out.. silly.
|
||||
cmd = '/usr/bin/git rev-list %s...%s' % (head.id, base.id)
|
||||
proc = sp.Popen(cmd.split(), stdout=sp.PIPE, stderr=sp.PIPE, cwd=abspath)
|
||||
proc = sp.Popen(
|
||||
cmd.split(),
|
||||
stdout=sp.PIPE,
|
||||
stderr=sp.PIPE,
|
||||
cwd=abspath,
|
||||
universal_newlines=True,
|
||||
)
|
||||
stdout, stderr = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
raise IOError('git rev-list failed: %r, err: %r' % (stdout, stderr))
|
||||
|
@ -114,7 +120,7 @@ for line in lines:
|
|||
revs = [head.id]
|
||||
|
||||
def _build_commit(rev):
|
||||
commit = repo.revparse_single(unicode(rev))
|
||||
commit = repo.revparse_single(rev)
|
||||
|
||||
# Tags are a little funny, and vary between versions of pygit2, so we'll
|
||||
# just ignore them as far as fedmsg is concerned.
|
||||
|
@ -133,7 +139,7 @@ for line in lines:
|
|||
files=files,
|
||||
total=total,
|
||||
),
|
||||
rev=unicode(rev),
|
||||
rev=rev,
|
||||
path=abspath,
|
||||
repo=repo_name,
|
||||
namespace=namespace,
|
||||
|
@ -141,7 +147,7 @@ for line in lines:
|
|||
agent=getlogin(),
|
||||
)
|
||||
|
||||
commits = map(_build_commit, revs)
|
||||
commits = [_build_commit(rev) for rev in revs]
|
||||
|
||||
print("* Publishing information for %i commits" % len(commits))
|
||||
for commit in reversed(commits):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue