[Asterisk-code-review] mkrelease: Delete old release branches (repotools[master])

George Joseph asteriskteam at digium.com
Wed Mar 14 10:28:22 CDT 2018


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/8292 )

Change subject: mkrelease: Delete old release branches
......................................................................

mkrelease: Delete old release branches

This patch makes it so when the first version of a new release (like a .0 or a
cert1 without other modifiers) is done the old release branch is automatically
deleted from the Asterisk repository.

Change-Id: I3928831feef237051c01413ef38ac1e82ffcb9cb
---
M digium_git.py
M mkrelease.py
2 files changed, 29 insertions(+), 1 deletion(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/digium_git.py b/digium_git.py
index e28642f..c76c953 100644
--- a/digium_git.py
+++ b/digium_git.py
@@ -54,6 +54,31 @@
     return DigiumGitRepo(path, repo_url=repo_url, show_progress=show_progress)
 
 
+def delete_previous_branch(repo, version):
+    """Using the given version object, get the last version and delete the
+    branch associated with that version.
+
+    Keyword Arguments:
+    repo - The repo containing the branch to delete
+    version - The current version being built (a version object)
+    """
+
+    # Only delete the previous branch when a first new release is made, which
+    # corresponds to a ".0" patch number or "cert1". Without any modifiers.
+    if not version.is_first():
+        return
+
+    # Find the last tag. We'll then use that as that to extract the branch name
+    prev = repo.find_last_tag(version)
+    if not prev:
+        return
+
+    branch = prev.branch_name()
+
+    LOGGER.debug("Deleting previous branch '{0}'".format(branch))
+    repo.delete_branch(branch)
+
+
 class GitProgressBar(RemoteProgress):
     """A progress bar that maintains the state of a Git operation
     """
diff --git a/mkrelease.py b/mkrelease.py
index 1a71067..83d85a1 100755
--- a/mkrelease.py
+++ b/mkrelease.py
@@ -18,7 +18,7 @@
 from datetime import datetime
 from optparse import OptionParser
 
-from digium_git import get_repo
+from digium_git import get_repo, delete_previous_branch
 from version_parser import AsteriskVersion
 from release_summary import ReleaseSummary, ReleaseSummaryOptions
 from alembic_creator import create_db_script
@@ -432,6 +432,9 @@
 
     prompt_to_continue("Confirm tag creation of '{0}'".format(version))
     repo.create_tag(version)
+    if options.project.lower() == 'asterisk':
+        # Delete the previous branch if needed
+        delete_previous_branch(repo, version_object)
 
 
 def create_hashes(archive, mod=None):

-- 
To view, visit https://gerrit.asterisk.org/8292
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3928831feef237051c01413ef38ac1e82ffcb9cb
Gerrit-Change-Number: 8292
Gerrit-PatchSet: 2
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180314/967f3f01/attachment.html>


More information about the asterisk-code-review mailing list