Skip to content

Commit 9f33328

Browse files
flound1129claude
andcommitted
chore(version): use unix timestamp for build versioning
Replaces git-describe-based versioning with a timestamp-based scheme. Each build produces a unique, monotonically increasing version of the form 0.1.0.dev{unix_timestamp}. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ce37cef commit 9f33328

File tree

2 files changed

+7
-36
lines changed

2 files changed

+7
-36
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def osx_check():
4646
_exclude_package_data = {}
4747
_entry_points = {'console_scripts': [], 'gui_scripts': [], 'deluge.ui': []}
4848
_data_files = []
49-
_version = get_version(prefix='squall-', suffix='.dev0')
49+
_version = get_version()
5050

5151

5252
class CleanDocs(Command):

version.py

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,19 @@
3131
#
3232

3333
import os
34-
import subprocess
34+
import time
3535

3636
__all__ = ('get_version',)
3737

38+
BASE_VERSION = '0.1.0'
3839
VERSION_FILE = os.path.join(os.path.dirname(__file__), 'RELEASE-VERSION')
3940

4041

41-
def call_git_describe(prefix='', suffix=''):
42-
cmd = 'git describe --tags --match %s[0-9]*' % prefix
43-
try:
44-
output = subprocess.check_output(cmd.split(), stderr=subprocess.PIPE)
45-
except (OSError, subprocess.CalledProcessError):
46-
return None
47-
else:
48-
version = output.decode('utf-8').strip().replace(prefix, '')
49-
# A dash signifies git commit increments since parent tag.
50-
if '-' in version:
51-
segment = '.dev' if 'dev' in version else '.post'
52-
version = segment.join(version.replace(suffix, '').split('-')[:2])
53-
return version
42+
def get_version():
43+
version = '%s.dev%d' % (BASE_VERSION, int(time.time()))
5444

55-
56-
def get_version(prefix='squall-', suffix='.dev0'):
57-
try:
58-
with open(VERSION_FILE) as f:
59-
release_version = f.readline().strip()
60-
except OSError:
61-
release_version = None
62-
63-
version = call_git_describe(prefix, suffix)
64-
65-
if not version:
66-
version = release_version
67-
if not version:
68-
raise ValueError(
69-
'Cannot find the version number! If you are using a git clone, '
70-
'please ensure you have tags fetched (e.g., git fetch --tags).'
71-
)
72-
73-
if version != release_version:
74-
with open(VERSION_FILE, 'w') as f:
75-
f.write('%s\n' % version)
45+
with open(VERSION_FILE, 'w') as f:
46+
f.write('%s\n' % version)
7647

7748
return version
7849

0 commit comments

Comments
 (0)