-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-version.py
executable file
·44 lines (32 loc) · 1.21 KB
/
get-version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python
from core_admin_common import command, support
import sys
import time
start = time.time ()
print "INFO: wait to avoid overwhelming github.."
# implement a random wait to avoid Too many requests error from github.com
from random import randint
from time import sleep
sleep (randint(1,20))
print "INFO: wait done (%d seconds waited).." % (time.time () - start)
(osname, oslongname, osversion) = support.get_os ()
release_name = osversion.split (" ")[1]
no_github_com_access = ["lenny", "squeeze", "wheezy", "centos6", "precise"]
if release_name in no_github_com_access:
command.run ("cp -f LATEST-VERSION VERSION")
sys.exit (0)
# end if
(status, info) = command.run ("""LANG=C git log | grep "^commit " | wc -l""")
if status:
print "ERROR: unable to get git version: %s" % info
sys.exit (-1)
# get versision
revision = int (info.strip ()) + 1
print "INFO: Revision found: %s" % revision
version = open ("VERSION").read ().split (".b")[0].strip ()
version = "%s.b%s" % (version, revision)
print "INFO: Updated vesion to: %s" % version
open ("VERSION", "w").write ("%s\n" % version)
open ("LATEST-VERSION", "w").write ("%s\n" % version)
# also update Changelog
command.run ("./update-changelog.sh")