Re: [FBR] fix the alternativearch git hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Pierre,

Pierre-Yves Chibon wrote:
> Good Morning Everyone,
> 
> While testing something in dist-git two days ago, we found out that there is a
> piece of code missing to the alternativearch git hook.
> 
> Here is the error we saw:
> Counting objects: 3, done.
> Delta compression using up to 4 threads.
> Compressing objects: 100% (3/3), done.
> Writing objects: 100% (3/3), 384 bytes | 384.00 KiB/s, done.
> Total 3 (delta 2), reused 0 (delta 0)
> remote: sh: /usr/lib/python2.7/site-packages/pagure/hooks/files/fedmsg_hook.py: No such file or directory

What about this separate error?  It looks like
fedmsg_hook.py was merged into default_hook.py in 638bb48d
("Merge the fedmsg notifications on commit logic into the
default hook", 2018-03-07)¹.

¹ https://pagure.io/pagure/c/638bb48d

> remote: Emitting a message to the fedmsg bus.
> remote: * Publishing information for 1 commits
> remote: Traceback (most recent call last):
> remote:   File "/usr/share/git-core/post-receive-alternativearch", line 206, in <module>
> remote:     run_as_post_receive_hook()
> remote:   File "/usr/share/git-core/post-receive-alternativearch", line 163, in run_as_post_receive_hook
> remote:     new_commits_list = get_revs_between(oldrev, newrev, abspath, refname)
> remote:   File "/usr/share/git-core/post-receive-alternativearch", line 96, in get_revs_between
> remote:     head = get_default_branch(abspath)
> remote: NameError: global name 'get_default_branch' is not defined
> remote: Sending to redis to send commit notification emails
> remote: * Publishing information for 1 commits
> remote: 
> remote: Create a pull-request for f27
> remote:    https://src.stg.fedoraproject.org/rpms/guake/diff/master..f27
> remote: 
> To ssh://pkgs.stg.fedoraproject.org/rpms/guake
>  * [new branch]      f27 -> f27
> 
> 
> 
> And here is the patch I would like to apply to fix it:
> diff --git a/roles/git/hooks/files/post-receive-alternativearch b/roles/git/hooks/files/post-receive-alternativearch
> index 7bc4a9a6a..8d93137e4 100755
> --- a/roles/git/hooks/files/post-receive-alternativearch
> +++ b/roles/git/hooks/files/post-receive-alternativearch
> @@ -100,6 +100,15 @@ def get_revs_between(oldrev, newrev, abspath, refname):
>      return read_git_lines(cmd, abspath)
> 
> 
> +def get_default_branch(abspath):
> +    """ Return the default branch of a repo. """
> +    cmd = ['rev-parse', '--abbrev-ref', 'HEAD']
> +    out = read_git_lines(cmd, abspath)
> +    if out:
> +        return out[0]
> +    else:
> +        return 'master'
> +
> 
>  def send_email(text, subject, to_mail):  # pragma: no cover
>      ''' Send an email with the specified information.

I don't count for +1, but the change looks good to me.

This could also work to drop the if/else return clause.

    branch = out and out[0] or 'master'
    return branch

-- 
Todd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you can stay calm, while all around you is chaos ... then you
probably haven't completely understood the situation.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
infrastructure mailing list -- infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to infrastructure-leave@xxxxxxxxxxxxxxxxxxxxxxx

[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux