def _run(self, force=False): # Determine the names of the relevant branches current_branch = util.current_branch() debian_branch = util.current_debian_branch() patch_queue_branch = util.current_patch_queue_branch() rhel_patches_branch = self.get_rhel_patches_branch(debian_branch) # Do the merge if current_branch == patch_queue_branch: # HEAD is our patch-queue branch. Use "git pull" directly. # For example: "git pull --ff-only patches/ceph-2-rhel-patches" cmd = ['git', 'pull', '--ff-only', 'patches/' + rhel_patches_branch] if force: # Do a hard reset on HEAD instead. cmd = ['git', 'reset', '--hard', 'patches/' + rhel_patches_branch] else: # HEAD is our debian branch. Use "git fetch" to update the # patch-queue ref. For example: # "git fetch . \ # patches/ceph-2-rhel-patches:patch-queue/ceph-2-ubuntu" util.ensure_patch_queue_branch() cmd = ['git', 'fetch', '.', 'patches/%s:%s' % (rhel_patches_branch, patch_queue_branch)] if force: # Do a hard push (with "+") instead. cmd = ['git', 'push', '.', '+patches/%s:%s' % (rhel_patches_branch, patch_queue_branch)] log.info(' '.join(cmd)) subprocess.check_call(cmd)
def _run(self, force=False): # Determine the names of the relevant branches current_branch = util.current_branch() debian_branch = util.current_debian_branch() patches_branch = util.current_patches_branch() rhel_patches_branch = self.get_rhel_patches_branch(debian_branch) # Do the merge if current_branch == patches_branch: # HEAD is our patch-queue branch. Use "git pull" directly. # For example: "git pull --ff-only patches/ceph-2-rhel-patches" cmd = ['git', 'pull', '--ff-only', 'patches/' + rhel_patches_branch] if force: # Do a hard reset on HEAD instead. cmd = ['git', 'reset', '--hard', 'patches/' + rhel_patches_branch] else: # HEAD is our debian branch. Use "git fetch" to update the # patch-queue ref. For example: # "git fetch . \ # patches/ceph-2-rhel-patches:patch-queue/ceph-2-ubuntu" cmd = ['git', 'fetch', '.', 'patches/%s:%s' % (rhel_patches_branch, patches_branch)] if force: # Do a hard push (with "+") instead. cmd = ['git', 'push', '.', '+patches/%s:%s' % (rhel_patches_branch, patches_branch)] log.info(' '.join(cmd)) subprocess.check_call(cmd)
def _run(self): debian_branch = util.current_debian_branch() try: flag = release_flag(debian_branch) except ValueError: raise SystemExit('could not parse debian branch "%s".' % debian_branch) msg = last_commit_message() bzids = find_bzs(msg) if not bzids: raise SystemExit('no BZs found') bzapi = get_bzapi() bugs = bzapi.getbugs(bzids, include_fields=['id', 'flags'], permissive=False) missing = [] for bug in bugs: has_release_flag = False for f in bug.flags: if f['name'] == flag: print('rhbz#%s: %s%s' % (bug.id, f['name'], f['status'])) has_release_flag = True if not has_release_flag: missing.append(bug.id) if missing: print('Missing %s release flag:' % flag) for m in missing: print('rhbz#%s' % m) raise SystemExit(1)
def _run(self, tarball, bugstr): # Ensure we're on the right branch. current_branch = util.current_branch() debian_branch = util.current_debian_branch() if current_branch != debian_branch: log.error('current branch is "%s"' % current_branch) log.error('debian branch is "%s"' % debian_branch) raise RuntimeError('Must run `new-version` on debian branch') util.setup_pristine_tar_branch() self.ensure_gbp_settings() self.setup_upstream_branch() self.import_orig(tarball) version = self.upstream_version() self.run_dch(version, bugstr) self.commit() self.show()
def test_current_debian_branch(self, testpkg): assert util.current_debian_branch() == 'ceph-2-ubuntu'
def _run(self): """ Generate quilt patch series with gbp pq, and update d/rules """ # Determine the names of the patch-queue branch and debian branch current_branch = util.current_branch() patch_queue_branch = util.current_patch_queue_branch() debian_branch = util.current_debian_branch() # TODO: default to fetching from upstream, the way rdopkg patch does. # Get the new sha1 to insert into the $COMMIT variable in d/rules cmd = ['git', 'rev-parse', patch_queue_branch] output = subprocess.check_output(cmd) patch_queue_sha1 = output.rstrip() if six.PY3: patch_queue_sha1 = output.decode('utf-8').rstrip() # Switch to "debian" branch if necessary if current_branch != debian_branch: cmd = ['git', 'checkout', debian_branch] subprocess.check_call(cmd) # Get the original (old) patch series old_series = self.read_series_file('debian/patches/series') old_subjects = [patch.subject for patch in old_series] # Git-buildpackage pq operation cmd = ['gbp', 'pq', 'export'] subprocess.check_call(cmd) # Add all patch files to Git's index cmd = ['git', 'add', '--all', 'debian/patches'] subprocess.check_call(cmd) # Bail early if gbp pq did nothing. if not self.read_git_debian_patches_status(): print('No new patches, quitting.') raise SystemExit(1) # Replace $COMMIT sha1 in d/rules old_sha1 = read_commit() if old_sha1: rules = read_rules_file() with open('debian/rules', 'w') as fileh: fileh.write(rules.replace(old_sha1, patch_queue_sha1)) # Get the new patch series new_series = self.read_series_file('debian/patches/series') # Select only the ones that are new (according to commit subjects) new_series = [p for p in new_series if p.subject not in old_subjects] if not new_series: # Maybe we rewrote some patch files in place? # Check Git itself for changed files: new_series = self.read_git_debian_patches() # Add patch entries to d/changelog changelog = self.generate_changelog(new_series) try: ensure_bzs(changelog) except BzNotFound: if not self.parser.has('--nobz'): raise util.bump_changelog(changelog) # Assemble a standard commit message string "clog". clog = "debian: %s\n" % util.get_deb_version() clog += "\n" clog += "Add patches from %s\n" % patch_queue_branch clog += "\n" clog += util.format_changelog(changelog) # Commit everything with the standard commit message. with tempfile.NamedTemporaryFile(mode='w+') as temp: temp.write(clog) temp.flush() cmd = [ 'git', 'commit', 'debian/changelog', 'debian/patches', 'debian/rules', '-F', temp.name ] subprocess.check_call(cmd) # Summarize this commit on STDOUT for the developer. # (This matches the behavior of "rdopkg patch".) cmd = ['git', '--no-pager', 'log', '--name-status', 'HEAD~..HEAD'] subprocess.check_call(cmd)
def _run(self): """ Generate quilt patch series with gbp pq, and update d/rules """ # Determine the names of the patch-queue branch and debian branch current_branch = util.current_branch() patches_branch = util.current_patches_branch() debian_branch = util.current_debian_branch() # TODO: default to fetching from upstream, the way rdopkg patch does. # Get the new sha1 to insert into the $COMMIT variable in d/rules cmd = ['git', 'rev-parse', patches_branch] patches_sha1 = subprocess.check_output(cmd).rstrip() # Switch to "debian" branch if necessary if current_branch != debian_branch: cmd = ['git', 'checkout', debian_branch] subprocess.check_call(cmd) # Get the original (old) patch series old_series = self.read_series_file('debian/patches/series') old_subjects = map(lambda x: x.subject, old_series) # Git-buildpackage pq operation cmd = ['gbp', 'pq', 'export'] subprocess.check_call(cmd) # Add all patch files to Git's index cmd = ['git', 'add', '--all', 'debian/patches'] subprocess.check_call(cmd) # Replace $COMMIT sha1 in d/rules with open('debian/rules') as rules: rules_file = rules.read() old = r'export COMMIT=[0-9a-f]{40}' new = 'export COMMIT=%s' % patches_sha1 with open('debian/rules', 'w') as fileh: fileh.write(re.sub(old, new, rules_file)) # Get the new patch series new_series = self.read_series_file('debian/patches/series') # Add patch entries to d/changelog changelog = [] for p in new_series: if p.subject in old_subjects: continue change = p.subject bzs = self.get_rhbzs(p) bzstr = ' '.join(map(lambda x: 'rhbz#%s' % x, bzs)) if bzstr != '': change += ' (%s)' % bzstr changelog.append(change) util.bump_changelog(changelog) # Assemble a standard commit message string "clog". clog = "debian: %s\n" % util.get_deb_version() clog += "\n" clog += "Add patches from %s\n" % patches_branch clog += "\n" clog += util.format_changelog(changelog) # Commit everything with the standard commit message. with tempfile.NamedTemporaryFile() as temp: temp.write(clog) temp.flush() cmd = [ 'git', 'commit', 'debian/changelog', 'debian/patches', 'debian/rules', '-F', temp.name ] subprocess.check_call(cmd) # Summarize this commit on STDOUT for the developer. # (This matches the behavior of "rdopkg patch".) cmd = ['git', '--no-pager', 'log', '--name-status', 'HEAD~..HEAD'] subprocess.check_call(cmd)
def test_current_patches_and_debian_branches(self, monkeypatch, current_branch): monkeypatch.setattr('rhcephpkg.util.current_branch', lambda: current_branch) assert util.current_patches_branch() == 'patch-queue/ceph-2-ubuntu' assert util.current_debian_branch() == 'ceph-2-ubuntu'
def test_current_debian_branch(self, testpkg, monkeypatch): assert util.current_debian_branch() == 'ceph-2-ubuntu'