Bug 481703 - Use python to create pre release suffix. r=bsmedberg
This commit is contained in:
Родитель
c9a0c6ecfa
Коммит
f333518fb6
|
@ -55,10 +55,8 @@ endif
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
PRE_RELEASE_SUFFIX = $(shell cat $(srcdir)/../config/version.txt | \
|
||||
sed -e '/pre/s/.*//g' -e '/[ab][0-9]/!s/.*//g' \
|
||||
-e 's/\(.*[0-9]\)a\([0-9]\+\)/ \1 Alpha \2/g' \
|
||||
-e 's/\(.*[0-9]\)b\([0-9]\+\)/ \1 Beta \2/g')
|
||||
PRE_RELEASE_SUFFIX := $(shell $(PYTHON) $(topsrcdir)/config/printprereleasesuffix.py \
|
||||
$(shell cat $(srcdir)/../config/version.txt))
|
||||
|
||||
DEFINES += \
|
||||
-DMOZ_APP_VERSION=$(MOZ_APP_VERSION) \
|
||||
|
|
|
@ -49,12 +49,9 @@ include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
|
|||
|
||||
CONFIG_DIR = instgen
|
||||
SFX_MODULE = $(topsrcdir)/other-licenses/7zstub/firefox/7zSD.sfx
|
||||
APP_VERSION = $(shell cat $(srcdir)/../../config/version.txt)
|
||||
APP_VERSION := $(shell cat $(srcdir)/../../config/version.txt)
|
||||
DEFINES += -DAPP_VERSION=$(APP_VERSION)
|
||||
PRE_RELEASE_SUFFIX = $(shell echo $(APP_VERSION) | \
|
||||
sed -e '/pre/s/.*//g' -e '/[ab][0-9]/!s/.*//g' \
|
||||
-e 's/\(.*[0-9]\)a\([0-9]\+\)/ \1 Alpha \2/g' \
|
||||
-e 's/\(.*[0-9]\)b\([0-9]\+\)/ \1 Beta \2/g')
|
||||
PRE_RELEASE_SUFFIX := $(shell $(PYTHON) $(topsrcdir)/config/printprereleasesuffix.py $(APP_VERSION))
|
||||
DEFINES += -DPRE_RELEASE_SUFFIX="$(PRE_RELEASE_SUFFIX)"
|
||||
|
||||
PP_LOCALIZED_FILES = \
|
||||
|
|
|
@ -154,7 +154,8 @@ clean clobber realclean clobber_all::
|
|||
cd $(MKDEPEND_DIR); $(MAKE) $@
|
||||
endif
|
||||
|
||||
PYUNITS := unit-Expression.py unit-Preprocessor.py unit-nsinstall.py
|
||||
PYUNITS := unit-Expression.py unit-Preprocessor.py unit-nsinstall.py \
|
||||
unit-printprereleasesuffix.py
|
||||
|
||||
check:: check-python-modules check-jar-mn
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# the Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2009
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Robert Strong <robert.bugzilla@gmail.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# Prints the pre-release version suffix based on the version string
|
||||
#
|
||||
# Examples:
|
||||
# 2.1a3 > " 2.1 Alpha 3"
|
||||
# 2.1a3pre > ""
|
||||
# 3.2b4 > " 3.2 Beta 4"
|
||||
# 3.2b4pre > ""
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
def get_prerelease_suffix(version):
|
||||
""" Returns the prerelease suffix from the version string argument """
|
||||
|
||||
def mfunc(m):
|
||||
return " %s %s %s" % (m.group('prefix'),
|
||||
{'a': 'Alpha', 'b': 'Beta'}[m.group('c')],
|
||||
m.group('suffix'))
|
||||
result, c = re.subn(r'^(?P<prefix>(\d+\.)*\d+)(?P<c>[ab])(?P<suffix>\d+)$',
|
||||
mfunc, version)
|
||||
if c != 1:
|
||||
return ''
|
||||
return result
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
print get_prerelease_suffix(sys.argv[1])
|
|
@ -0,0 +1,80 @@
|
|||
import unittest
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from printprereleasesuffix import get_prerelease_suffix
|
||||
|
||||
class TestGetPreReleaseSuffix(unittest.TestCase):
|
||||
"""
|
||||
Unit tests for the get_prerelease_suffix function
|
||||
"""
|
||||
|
||||
def test_alpha_1(self):
|
||||
"""test 1a1 version string"""
|
||||
self.c = get_prerelease_suffix('1a1')
|
||||
self.assertEqual(self.c, ' 1 Alpha 1')
|
||||
|
||||
def test_alpha_10(self):
|
||||
"""test 1.2a10 version string"""
|
||||
self.c = get_prerelease_suffix('1.2a10')
|
||||
self.assertEqual(self.c, ' 1.2 Alpha 10')
|
||||
|
||||
def test_beta_3(self):
|
||||
"""test 1.2.3b3 version string"""
|
||||
self.c = get_prerelease_suffix('1.2.3b3')
|
||||
self.assertEqual(self.c, ' 1.2.3 Beta 3')
|
||||
|
||||
def test_beta_30(self):
|
||||
"""test 1.2.3.4b30 version string"""
|
||||
self.c = get_prerelease_suffix('1.2.3.4b30')
|
||||
self.assertEqual(self.c, ' 1.2.3.4 Beta 30')
|
||||
|
||||
def test_release_1(self):
|
||||
"""test 1.2.3.4 version string"""
|
||||
self.c = get_prerelease_suffix('1.2.3.4')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
def test_alpha_1_pre(self):
|
||||
"""test 1.2a1pre version string"""
|
||||
self.c = get_prerelease_suffix('1.2a1pre')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
def test_beta_10_pre(self):
|
||||
"""test 3.4b10pre version string"""
|
||||
self.c = get_prerelease_suffix('3.4b10pre')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
def test_pre_0(self):
|
||||
"""test 1.2pre0 version string"""
|
||||
self.c = get_prerelease_suffix('1.2pre0')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
def test_pre_1_b(self):
|
||||
"""test 1.2pre1b version string"""
|
||||
self.c = get_prerelease_suffix('1.2pre1b')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
def test_a_a(self):
|
||||
"""test 1.2aa version string"""
|
||||
self.c = get_prerelease_suffix('1.2aa')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
def test_b_b(self):
|
||||
"""test 1.2bb version string"""
|
||||
self.c = get_prerelease_suffix('1.2bb')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
def test_a_b(self):
|
||||
"""test 1.2ab version string"""
|
||||
self.c = get_prerelease_suffix('1.2ab')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
def test_plus(self):
|
||||
"""test 1.2+ version string """
|
||||
self.c = get_prerelease_suffix('1.2+')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Загрузка…
Ссылка в новой задаче