See ticket: https://fedorahosted.org/fedora-infrastructure/ticket/4680 Basically git decides sometimes if it thinks it's a good idea to pack the refs for a repo. This includes the head refs. Then they no longer appear under refs/heads/ but instead are in a packed-refs file listing them all. Currently pkgdb_sync_git_branches.py just looks for refs/heads/* in 2 places to decide what it should do. We replace one with a 'git show-ref --heads' and the other with a 'git branch' to get existing branches. This is needed to fix sending an error to libguestfs maintainers everytime genacls runs in production. It's been tested on pkgs01.stg and works there (with the libguestfs synced from prod). +1s? kevin -- diff --git a/roles/distgit/templates/pkgdb_sync_git_branches.py b/roles/distgit/templates/pkgdb_sync_git_branches.py index 8643165..fc4e6b3 100644 --- a/roles/distgit/templates/pkgdb_sync_git_branches.py +++ b/roles/distgit/templates/pkgdb_sync_git_branches.py @@ -100,6 +100,15 @@ def _invoke(program, args): e.message = 'Error, "%s" returned %s' % (e.cmd, e.returnCode) raise e +def _call_cmd(command): + ''' Call the given command with the given arguments, all provided as a list + and return the output from this command. + ''' + if isinstance(command, basestring): + command = command.split() + output = subprocess.Popen(command, stdout=subprocess.PIPE).stdout.read()[:-1] + return output + def _create_branch(pkgname, branch): '''Create a specific branch for a package. @@ -108,23 +117,23 @@ def _create_branch(pkgname, branch): :arg branch: Name of the branch to create ''' + branch = branch.replace('*', '').strip() if branch == 'master': print 'ERROR: Proudly refusing to create master branch. Invalid repo?' print 'INFO: Please check %s repo' % pkgname return - branchpath = os.path.join( - GIT_FOLDER, '%s.git' % pkgname, 'refs/heads', branch) - if not os.path.exists(branchpath): - try: + os.chdir(os.path.join(GIT_FOLDER, '%s.git' % pkgname)) + branches = get_git_branch(pkgname) + if branch not in branches: + try: _invoke(MKBRANCH, [branch, pkgname]) - except ProcessError, e: + except ProcessError, e: if e.returnCode == 255: # This is a warning, not an error return raise - finally: - fedmsg.publish( + fedmsg.publish( topic='branch', modname='git', msg=dict( @@ -133,9 +142,8 @@ def _create_branch(pkgname, branch): branch=branch, ), ) - elif VERBOSE: - print 'Was asked to create branch %s of package %s, but it '\ - 'already exists' % (pkgname, branch) + else: + print 'Odd I was asked to create a branch %s that exists' % branch def pkgdb_pkg_branch(): @@ -171,8 +179,11 @@ def get_git_branch(pkg): print 'Could not find %s' % git_folder return set() - head_folder = os.path.join(git_folder, 'refs', 'heads') - return set(os.listdir(head_folder)) + branches = [ + lclbranch.replace('*', '').strip() + for lclbranch in _call_cmd(['git', 'branch']).split('\n') + ] + return set(branches) def branch_package(pkgname, branches): @@ -187,19 +198,18 @@ def branch_package(pkgname, branches): # Create the devel branch if necessary if not os.path.exists( - os.path.join(GIT_FOLDER, '%s.git/refs/heads/master' % pkgname)): + os.path.join(GIT_FOLDER, '%s.git' % pkgname)): _invoke(SETUP_PACKAGE, [pkgname]) - if 'master' in branches: - branches.remove('master') # SETUP_PACKAGE creates master - fedmsg.publish( - topic='branch', - modname='git', - msg=dict( - agent='pkgdb', - name=pkgname, - branch='master', - ), - ) + branches.remove('master') # SETUP_PACKAGE creates master + fedmsg.publish( + topic='branch', + modname='git', + msg=dict( + agent='pkgdb', + name=pkgname, + branch='master', + ), + ) # Create all the required branches for the package # Use the translated branch name until pkgdb falls inline
Attachment:
pgpuXbKqMesFV.pgp
Description: OpenPGP digital signature
_______________________________________________ infrastructure mailing list infrastructure@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/infrastructure