[Asterisk-code-review] mkrelease: Fix patch file on releases. (repotools[master])

Joshua Colp asteriskteam at digium.com
Tue Nov 1 06:17:42 CDT 2016


Joshua Colp has uploaded a new change for review. ( https://gerrit.asterisk.org/4256 )

Change subject: mkrelease: Fix patch file on releases.
......................................................................

mkrelease: Fix patch file on releases.

This change makes it so that the patch file for releases
are the diff between the last released version and the
new one. This allows people who run only releases (not rc)
to use the patch to remain up to date. For the release
candidates they will remain as they are, the diff between
the last release version or last rc.

ASTERISK-26502 #close

Change-Id: I43807052719243747037f9eba12f995f97c8f49a
---
M mkrelease.py
1 file changed, 21 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/repotools refs/changes/56/4256/1

diff --git a/mkrelease.py b/mkrelease.py
index 1a6c478..0ba76e6 100755
--- a/mkrelease.py
+++ b/mkrelease.py
@@ -475,7 +475,7 @@
         gpg.sign_file(file_stream, detach=True, output=out_file)
 
 
-def create_patch_archive(options):
+def create_patch_archive(options, repo):
     """Create an archive of the diff between this release and the previous
 
     Keyword Arguments:
@@ -489,14 +489,32 @@
                "diff".format(version))
         return
 
+    if len(version_object.modifiers) == 0:
+        # If this is a full release use the previously released version (including patch) to
+        # generate the patch from.
+        search = True
+        i = 0
+
+        # The previous version does not include the patch, so determine what the patch is up to
+        while search:
+            if not repo.tag_exists('{0}.{1}.{2}'.format(prev_obj.major, prev_obj.minor, i)):
+                search = False
+            else:
+                diff_version = '{0}.{1}.{2}'.format(prev_obj.major, prev_obj.minor, i)
+                i += 1
+    else:
+        # For non-full releases use the actual start of the history for the
+        # release.
+        diff_version = start_version
+
     # Since we don't want to work with the diff, but merely dump it out,
     # this is more easily done via the command line
     curdir = os.getcwd()
     os.chdir(os.path.join(options.local_root, options.project))
     file_name = '{0}-patch'.format(release_name)
-    LOGGER.debug("Generating diff from '{0}' to '{1}'".format(start_version,
+    LOGGER.debug("Generating diff from '{0}' to '{1}'".format(diff_version,
                                                         version))
-    os.system('git diff {0}..{1} > {2}'.format(start_version,
+    os.system('git diff {0}..{1} > {2}'.format(diff_version,
                                                version,
                                                file_name))
     os.chdir(curdir)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I43807052719243747037f9eba12f995f97c8f49a
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list