[Asterisk-code-review] build: Start with a current branch during release. (...repotools[master])

Joshua Colp asteriskteam at digium.com
Tue Jun 4 04:18:25 CDT 2019


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/repotools/+/11425 )

Change subject: build: Start with a current branch during release.
......................................................................

build: Start with a current branch during release.

When running the scripts manually during the release, the second script
failed because there was no starting branch. Now, an option can be
passed to get_repo that will check out the specified branch. This allows
the script to commit and push changes to the appropriate branch without
having to constantly switch branches manually.

Change-Id: I5c3496a1cc362895fb1f88e0061cbf0eea440f97
---
M commit-staging-changes
M digium_git.py
M process-staging-changes
3 files changed, 14 insertions(+), 5 deletions(-)

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



diff --git a/commit-staging-changes b/commit-staging-changes
index fc4c1f7..3c4d331 100755
--- a/commit-staging-changes
+++ b/commit-staging-changes
@@ -15,13 +15,15 @@
                         help="The local root to work from", default="/tmp")
     parser.add_argument("-v", "--version", dest="version",
                         help="The version to be released", required=True)
+    parser.add_argument("-b", "--branch", dest="branch",
+                        help="The branch we are currently on", required=True)
 
     (ns, args) = parser.parse_known_args()
 
     logging.basicConfig(level=logging.DEBUG, format="%(module)s:%(lineno)d - %(message)s")
 
     # Default to asterisk and gerrit URL
-    repo = get_repo(local_root=ns.local_root)
+    repo = get_repo(local_root=ns.local_root, ns.branch)
 
     LOGGER.debug("Adding and committing all staging changes")
 
diff --git a/digium_git.py b/digium_git.py
index bbf1463..5741064 100644
--- a/digium_git.py
+++ b/digium_git.py
@@ -30,7 +30,7 @@
 
 
 def get_repo(project=None, local_root=None, remote_url=None,
-             show_progress=False):
+             show_progress=False, branch=None):
     """Prepare the repo that the release will be made from
 
     Keyword Arguments:
@@ -39,6 +39,7 @@
         checked out under (default '/tmp')
     remote_url - The remote url for the repository (default GERRIT)
     show_progress - False (default) if a progress bar should not be shown
+    branch - The branch to initially checkout
 
     Returns:
     A DigiumGitRepo object
@@ -51,7 +52,8 @@
     repo_url = '{0}/{1}'.format(remote_url, project)
 
     LOGGER.debug("Cloning from '{0}' to '{1}'".format(repo_url, path))
-    return DigiumGitRepo(path, repo_url=repo_url, show_progress=show_progress)
+    return DigiumGitRepo(path, repo_url=repo_url, show_progress=show_progress,
+                         branch=branch)
 
 
 def delete_previous_branch(repo, version):
@@ -176,7 +178,8 @@
     and fetching the repo, providing useful logs/summaries, etc.
     """
 
-    def __init__(self, local_path, repo_url=None, show_progress=False):
+    def __init__(self, local_path, repo_url=None, show_progress=False,
+                 branch=None):
         """Constructor
 
         Keyword Arguments:
@@ -191,6 +194,7 @@
                         provided.
         show_progress - If True, print out a progress bar for the various
                         operations being performed.
+        branch        - The branch to initially check out, if any.
         """
 
         self.show_progress = show_progress
@@ -220,6 +224,9 @@
         origin.fetch(progress=self.progress)
         origin.fetch("--tags")
 
+        if branch is not None:
+            self.checkout(branch)
+
     @property
     def progress(self):
         """Get a progress bar if set to show"""
diff --git a/process-staging-changes b/process-staging-changes
index 4efe98b..ce9086c 100755
--- a/process-staging-changes
+++ b/process-staging-changes
@@ -27,6 +27,6 @@
         if ns.local_root != "/tmp/":
             used_l_opt = "-l {0} ".format(ns.local_root)
         print("Done! Check {0}asterisk and make sure everything looks right. "
-              "Then run 'commit-staging-changes {1}-v {2}'.".format(ns.local_root, used_l_opt, ns.end_version))
+              "Then run 'commit-staging-changes {1}-v {2}' -b <current_branch>.".format(ns.local_root, used_l_opt, ns.end_version))
     else:
         print("Error! Check the logs and remember to clean up {0}asterisk".format(ns.local_root))

-- 
To view, visit https://gerrit.asterisk.org/c/repotools/+/11425
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Change-Id: I5c3496a1cc362895fb1f88e0061cbf0eea440f97
Gerrit-Change-Number: 11425
Gerrit-PatchSet: 1
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190604/936bd22e/attachment.html>


More information about the asterisk-code-review mailing list