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,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
cwd=abspath,
|
cwd=abspath,
|
||||||
|
universal_newlines=True,
|
||||||
**kw)
|
**kw)
|
||||||
(out, err) = procs.communicate(input)
|
(out, err) = procs.communicate(input)
|
||||||
retcode = procs.wait()
|
retcode = procs.wait()
|
||||||
|
@ -66,7 +67,7 @@ def read_output(cmd, abspath, input=None, keepends=False, **kw):
|
||||||
print(err)
|
print(err)
|
||||||
if not keepends:
|
if not keepends:
|
||||||
out = out.rstrip('\n\r')
|
out = out.rstrip('\n\r')
|
||||||
return unicode(out, errors='ignore')
|
return out
|
||||||
|
|
||||||
|
|
||||||
def read_git_output(args, abspath, input=None, keepends=False, **kw):
|
def read_git_output(args, abspath, input=None, keepends=False, **kw):
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
pee \
|
pee \
|
||||||
/usr/share/git-core/post-receive-fedora-messaging \
|
/usr/share/git-core/post-receive-fedora-messaging \
|
||||||
/usr/share/git-core/post-receive-alternativearch \
|
/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`"
|
"/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
|
# 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.
|
# 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)
|
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()
|
stdout, stderr = proc.communicate()
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
raise IOError('git rev-list failed: %r, err: %r' % (stdout, stderr))
|
raise IOError('git rev-list failed: %r, err: %r' % (stdout, stderr))
|
||||||
|
@ -114,7 +120,7 @@ for line in lines:
|
||||||
revs = [head.id]
|
revs = [head.id]
|
||||||
|
|
||||||
def _build_commit(rev):
|
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
|
# Tags are a little funny, and vary between versions of pygit2, so we'll
|
||||||
# just ignore them as far as fedmsg is concerned.
|
# just ignore them as far as fedmsg is concerned.
|
||||||
|
@ -133,7 +139,7 @@ for line in lines:
|
||||||
files=files,
|
files=files,
|
||||||
total=total,
|
total=total,
|
||||||
),
|
),
|
||||||
rev=unicode(rev),
|
rev=rev,
|
||||||
path=abspath,
|
path=abspath,
|
||||||
repo=repo_name,
|
repo=repo_name,
|
||||||
namespace=namespace,
|
namespace=namespace,
|
||||||
|
@ -141,7 +147,7 @@ for line in lines:
|
||||||
agent=getlogin(),
|
agent=getlogin(),
|
||||||
)
|
)
|
||||||
|
|
||||||
commits = map(_build_commit, revs)
|
commits = [_build_commit(rev) for rev in revs]
|
||||||
|
|
||||||
print("* Publishing information for %i commits" % len(commits))
|
print("* Publishing information for %i commits" % len(commits))
|
||||||
for commit in reversed(commits):
|
for commit in reversed(commits):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue