~brian-murray/ubuntu-archive-tools/pu-stopped-email

« back to all changes in this revision

Viewing changes to branch-seeds

  • Committer: Łukasz 'sil2100' Zemczak
  • Date: 2020-04-24 18:17:09 UTC
  • Revision ID: lukasz.zemczak@canonical.com-20200424181709-kupor6v4wa7mv6bd
Make branch-seeds wait a bit for the new git refs to appear before attempting to set the default_branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from optparse import OptionParser
23
23
import os
24
24
import re
 
25
import time
25
26
import subprocess
26
27
try:
27
28
    from urllib.parse import urlparse
134
135
                if "git.launchpad.net" in remote:
135
136
                    lp_git_repo = options.launchpad.git_repositories.getByPath(
136
137
                        path=urlparse(remote).path.lstrip("/"))
137
 
                    lp_git_repo.default_branch = options.dest_series
138
 
                    lp_git_repo.lp_save()
 
138
                    new_ref = "refs/heads/%s" % options.dest_series
 
139
                    # Sometimes it takes LP a while to notice the new ref
 
140
                    for i in range(10):
 
141
                        if lp_git_repo.getRefByPath(path=new_ref):
 
142
                            lp_git_repo.default_branch = new_ref
 
143
                            lp_git_repo.lp_save()
 
144
                            break
 
145
                        time.sleep(1)
 
146
                    else:
 
147
                        raise Exception(
 
148
                            "Was unable to set default_branch of %s after "
 
149
                            "multiple retries - proceed manually." % remote)
139
150
                else:
140
151
                    raise Exception(
141
152
                        "Git remote URL must be on git.launchpad.net.")