jenkins-bot has submitted this change and it was merged.

Change subject: semantic version support + special casing old versions, offline 
builds, not svn
......................................................................


semantic version support + special casing old versions, offline builds, not svn

* Added support in the newer releases (1.23.0-rc.1 and forward) for
  Semantic Versioning.

  This also involved special casing so that diffs with older versions
  (1.23.0rc0 and before) that didn't use semantic versioning.

* Added support for offline creation of tarballs with "--offline"
  option.  Used this while flying back from Zűrich.

* Switched "trunk" which was left over from svn to "master" for the
  new git awesomeness.

Change-Id: I6fbe8b07572a64204673e2491d56e2199b2df40a
---
M make-release/make-release.py
M make-release/tests/test_mwversion.py
2 files changed, 91 insertions(+), 21 deletions(-)

Approvals:
  MarkAHershberger: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/make-release/make-release.py b/make-release/make-release.py
index f9051f0..2298f4a 100755
--- a/make-release/make-release.py
+++ b/make-release/make-release.py
@@ -165,6 +165,11 @@
         default='tar',
         help='path to tar, we are expecting a GNU tar. (defaults to tar)'
     )
+    parser.add_argument(
+        '--offline', dest='offline',
+        default=False, action='store_true',
+        help='Do not perform actions (e.g. git pull) that require the network'
+    )
 
     return parser.parse_args()
 
@@ -227,8 +232,8 @@
             (?P<major>(?P<major1>\d+)\.(?P<major2>\d+))
             \.
             (?P<minor>\d+)
-            (?:
-                (?P<phase>[A-Za-z]+)
+            (?:-?
+                (?P<phase>[A-Za-z]+)\.?
                 (?P<cycle>\d+)
             )?
         """, re.X).match(version)
@@ -247,24 +252,48 @@
         del ret['major1']
         del ret['major2']
 
-        ret['tag'] = 'tags/%s.%s%s%s' % (
-            ret['major'],
-            ret['minor'],
-            ret.get('phase', ''),
-            ret.get('cycle', '')
-        )
+        # Special case for when we switched to semantic versioning
+        if(ret['major'] <= '1.22' or
+           (ret['major'] == '1.23' and
+            ret['minor'] == '0' and
+            (ret['phase'] == 'rc' and
+             ret['cycle'] == '0'))):
+            ret['tag'] = 'tags/%s.%s%s%s' % (
+                ret['major'],
+                ret['minor'],
+                ret.get('phase', ''),
+                ret.get('cycle', '')
+            )
+        else:
+            ret['tag'] = 'tags/%s.%s-%s.%s' % (
+                ret['major'],
+                ret['minor'],
+                ret.get('phase', ''),
+                ret.get('cycle', '')
+            )
 
         last = m.group(m.lastindex)
         if int(last) == 0:
             ret['prevVersion'] = None
+            ret['prevTag'] = None
             return ret
 
         bits = [d for d in m.groups('')]
-        bits[m.lastindex - 1] = str(int(bits[m.lastindex - 1]) - 1)
+        last = m.lastindex - 3
         del bits[1]
         del bits[1]
 
-        ret['prevVersion'] = '%s.%s%s%s' % tuple(bits)
+        bits[last] = str(int(bits[last]) - 1)
+
+        if(bits[0] <= '1.22' or
+           (bits[0] == '1.23' and
+            bits[1] == '0' and
+            (bits[2] == 'rc' and
+             bits[3] == '0'))):
+            ret['prevVersion'] = '%s.%s%s%s' % tuple(bits)
+        else:
+            ret['prevVersion'] = '%s.%s-%s.%s' % tuple(bits)
+
         ret['prevTag'] = 'tags/' + ret['prevVersion']
 
         return ret
@@ -371,21 +400,22 @@
                 print "Could not update local repository %s" % repo
                 sys.exit(1)
 
-        if (os.path.exists(dir)):
-            print "Updating " + label + " in " + dir + "..."
-            proc = subprocess.Popen(
-                ['sh', '-c', 'cd ' + dir + '; git fetch -q --all'])
-        else:
-            print "Cloning " + label + " into " + dir + "..."
-            proc = subprocess.Popen(['git', 'clone', '-q', repo, dir])
+        if not self.options.offline:
+            if (os.path.exists(dir)):
+                print "Updating " + label + " in " + dir + "..."
+                proc = subprocess.Popen(
+                    ['sh', '-c', 'cd ' + dir + '; git fetch -q --all'])
+            else:
+                print "Cloning " + label + " into " + dir + "..."
+                proc = subprocess.Popen(['git', 'clone', '-q', repo, dir])
 
-        if proc.wait() != 0:
-            print "git clone failed, exiting"
-            sys.exit(1)
+            if proc.wait() != 0:
+                print "git clone failed, exiting"
+                sys.exit(1)
 
         os.chdir(dir)
 
-        if branch != 'trunk':
+        if branch != 'master' and branch is not None:
             print "Checking out %s in %s..." % (branch, dir)
             proc = subprocess.Popen(['git', 'checkout', branch])
 
diff --git a/make-release/tests/test_mwversion.py 
b/make-release/tests/test_mwversion.py
index 0372315..b90935b 100644
--- a/make-release/tests/test_mwversion.py
+++ b/make-release/tests/test_mwversion.py
@@ -99,3 +99,43 @@
         observed = makerelease.MwVersion('1.22')
         expected = FakeVersion({'raw': '1.22'})
         self.assertMwVersionEqual(expected, observed)
+
+    def test_special_case_1(self):
+        observed = makerelease.MwVersion('1.23.0rc0')
+        expected = FakeVersion({
+            'raw': '1.23.0rc0',
+            'major': '1.23',
+            'branch': 'REL1_23',
+            'tag': 'tags/1.23.0rc0',
+            'phase': 'rc',
+            'cycle': '0',
+            })
+        self.assertMwVersionEqual(expected, observed)
+
+    def test_special_case_2(self):
+        observed = makerelease.MwVersion('1.23.0-rc.1')
+        expected = FakeVersion({
+            'raw': '1.23.0-rc.1',
+            'major': '1.23',
+            'branch': 'REL1_23',
+            'tag': 'tags/1.23.0-rc.1',
+            'prev_tag': 'tags/1.23.0rc0',
+            'prev_version': '1.23.0rc0',
+            'phase': 'rc',
+            'cycle': '1',
+            })
+        self.assertMwVersionEqual(expected, observed)
+
+    def test_special_case_3(self):
+        observed = makerelease.MwVersion('1.23.0-rc.2')
+        expected = FakeVersion({
+            'raw': '1.23.0-rc.2',
+            'major': '1.23',
+            'branch': 'REL1_23',
+            'tag': 'tags/1.23.0-rc.2',
+            'prev_tag': 'tags/1.23.0-rc.1',
+            'prev_version': '1.23.0-rc.1',
+            'phase': 'rc',
+            'cycle': '2',
+            })
+        self.assertMwVersionEqual(expected, observed)

-- 
To view, visit https://gerrit.wikimedia.org/r/133221
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6fbe8b07572a64204673e2491d56e2199b2df40a
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/tools/release
Gerrit-Branch: master
Gerrit-Owner: MarkAHershberger <m...@nichework.com>
Gerrit-Reviewer: MarkAHershberger <m...@nichework.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to