Skip to content
This repository was archived by the owner on Oct 18, 2020. It is now read-only.

Commit c21f7d9

Browse files
committed
Release 1.5.2.rc1
Review URL: https://codereview.appspot.com/299220043 .
1 parent 43960e2 commit c21f7d9

File tree

8 files changed

+150
-24
lines changed

8 files changed

+150
-24
lines changed

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
include version.py
22
include version.yaml
33
include README.md
4+
include _version.py
5+
46
recursive-include resources *
57
recursive-include src *.c *.h *.py
68
recursive-include test_data *

_version.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
# Machine Generated - do not edit!
3+
4+
# This file is produced when the main "version.py update" command is run. That
5+
# command copies this file to all sub-packages which contain
6+
# setup.py. Configuration is maintain in version.yaml at the project's top
7+
# level.
8+
9+
def get_versions():
10+
return tag_version_data(raw_versions(), """version.yaml""")
11+
12+
def raw_versions():
13+
return json.loads("""
14+
{
15+
"codename": "Furka",
16+
"version": "1.5.2",
17+
"post": "0",
18+
"rc": "1"
19+
}
20+
""")
21+
22+
import json
23+
import os
24+
import subprocess
25+
26+
try:
27+
# We are looking for the git repo which contains this file.
28+
MY_DIR = os.path.dirname(__file__)
29+
except:
30+
MY_DIR = None
31+
32+
def is_tree_dirty():
33+
try:
34+
return bool(subprocess.check_output(
35+
["git", "diff", "--name-only"], stderr=subprocess.PIPE,
36+
cwd=MY_DIR,
37+
).splitlines())
38+
except (OSError, subprocess.CalledProcessError):
39+
return False
40+
41+
def get_version_file_path(version_file="version.yaml"):
42+
try:
43+
return os.path.join(subprocess.check_output(
44+
["git", "rev-parse", "--show-toplevel"], stderr=subprocess.PIPE,
45+
cwd=MY_DIR,
46+
).strip(), version_file)
47+
except (OSError, subprocess.CalledProcessError):
48+
return None
49+
50+
def number_of_commit_since(version_file="version.yaml"):
51+
"""Returns the number of commits since version.yaml was changed."""
52+
try:
53+
last_commit_to_touch_version_file = subprocess.check_output(
54+
["git", "log", "--no-merges", "-n", "1", "--pretty=format:%H",
55+
version_file], cwd=MY_DIR, stderr=subprocess.PIPE,
56+
).strip()
57+
58+
all_commits = subprocess.check_output(
59+
["git", "log", "--no-merges", "-n", "1000", "--pretty=format:%H"],
60+
stderr=subprocess.PIPE, cwd=MY_DIR,
61+
).splitlines()
62+
return all_commits.index(last_commit_to_touch_version_file)
63+
except (OSError, subprocess.CalledProcessError, ValueError):
64+
return None
65+
66+
67+
def get_current_git_hash():
68+
try:
69+
return subprocess.check_output(
70+
["git", "log", "--no-merges", "-n", "1", "--pretty=format:%H"],
71+
stderr=subprocess.PIPE, cwd=MY_DIR,
72+
).strip()
73+
except (OSError, subprocess.CalledProcessError):
74+
return None
75+
76+
def tag_version_data(version_data, version_path="version.yaml"):
77+
current_hash = get_current_git_hash()
78+
# Not in a git repository.
79+
if current_hash is None:
80+
version_data["error"] = "Not in a git repository."
81+
82+
else:
83+
version_data["revisionid"] = current_hash
84+
version_data["dirty"] = is_tree_dirty()
85+
version_data["dev"] = number_of_commit_since(
86+
get_version_file_path(version_path))
87+
88+
# Format the version according to pep440:
89+
pep440 = version_data["version"]
90+
if int(version_data.get("post", 0)) > 0:
91+
pep440 += ".post" + version_data["post"]
92+
93+
elif int(version_data.get("rc", 0)) > 0:
94+
pep440 += ".rc" + version_data["rc"]
95+
96+
if version_data.get("dev", 0):
97+
pep440 += ".dev" + str(version_data["dev"])
98+
99+
version_data["pep440"] = pep440
100+
101+
return version_data

rekall-core/rekall/_version.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ def get_versions():
1212
def raw_versions():
1313
return json.loads("""
1414
{
15-
"codename": "Furka",
16-
"version": "1.5.1",
17-
"post": "2"
15+
"codename": "Furka",
16+
"version": "1.5.2",
17+
"post": "0",
18+
"rc": "1"
1819
}
1920
""")
2021

@@ -41,7 +42,7 @@ def get_version_file_path(version_file="version.yaml"):
4142
try:
4243
return os.path.join(subprocess.check_output(
4344
["git", "rev-parse", "--show-toplevel"], stderr=subprocess.PIPE,
44-
cwd=MY_DIR,
45+
cwd=MY_DIR,
4546
).strip(), version_file)
4647
except (OSError, subprocess.CalledProcessError):
4748
return None
@@ -82,13 +83,16 @@ def tag_version_data(version_data, version_path="version.yaml"):
8283
version_data["revisionid"] = current_hash
8384
version_data["dirty"] = is_tree_dirty()
8485
version_data["dev"] = number_of_commit_since(
85-
get_version_file_path(version_path))
86+
get_version_file_path(version_path))
8687

8788
# Format the version according to pep440:
8889
pep440 = version_data["version"]
89-
if version_data.get("post"):
90+
if int(version_data.get("post", 0)) > 0:
9091
pep440 += ".post" + version_data["post"]
9192

93+
elif int(version_data.get("rc", 0)) > 0:
94+
pep440 += ".rc" + version_data["rc"]
95+
9296
if version_data.get("dev", 0):
9397
pep440 += ".dev" + str(version_data["dev"])
9498

rekall-gui/_version.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ def raw_versions():
1313
return json.loads("""
1414
{
1515
"codename": "Furka",
16-
"version": "1.5.1",
17-
"post": "2"
16+
"version": "1.5.2",
17+
"post": "0",
18+
"rc": "1"
1819
}
1920
""")
2021

@@ -41,7 +42,7 @@ def get_version_file_path(version_file="version.yaml"):
4142
try:
4243
return os.path.join(subprocess.check_output(
4344
["git", "rev-parse", "--show-toplevel"], stderr=subprocess.PIPE,
44-
cwd=MY_DIR,
45+
cwd=MY_DIR,
4546
).strip(), version_file)
4647
except (OSError, subprocess.CalledProcessError):
4748
return None
@@ -82,13 +83,16 @@ def tag_version_data(version_data, version_path="version.yaml"):
8283
version_data["revisionid"] = current_hash
8384
version_data["dirty"] = is_tree_dirty()
8485
version_data["dev"] = number_of_commit_since(
85-
get_version_file_path(version_path))
86+
get_version_file_path(version_path))
8687

8788
# Format the version according to pep440:
8889
pep440 = version_data["version"]
89-
if version_data.get("post"):
90+
if int(version_data.get("post", 0)) > 0:
9091
pep440 += ".post" + version_data["post"]
9192

93+
elif int(version_data.get("rc", 0)) > 0:
94+
pep440 += ".rc" + version_data["rc"]
95+
9296
if version_data.get("dev", 0):
9397
pep440 += ".dev" + str(version_data["dev"])
9498

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
from setuptools.command.install import install as _install
3232
from setuptools.command.develop import develop as _develop
3333

34-
ENV = {"__file__": __file__}
35-
exec open("rekall-core/rekall/_version.py").read() in ENV
36-
VERSION = ENV["get_versions"]()
34+
import _version
35+
VERSION = _version.get_versions()
3736

3837
rekall_description = "Rekall Memory Forensic Framework"
3938

tools/layout_expert/layout_expert/_version.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ def raw_versions():
1313
return json.loads("""
1414
{
1515
"codename": "Furka",
16-
"version": "1.5.1",
17-
"post": "2"
16+
"version": "1.5.2",
17+
"post": "0",
18+
"rc": "1"
1819
}
1920
""")
2021

@@ -41,7 +42,7 @@ def get_version_file_path(version_file="version.yaml"):
4142
try:
4243
return os.path.join(subprocess.check_output(
4344
["git", "rev-parse", "--show-toplevel"], stderr=subprocess.PIPE,
44-
cwd=MY_DIR,
45+
cwd=MY_DIR,
4546
).strip(), version_file)
4647
except (OSError, subprocess.CalledProcessError):
4748
return None
@@ -82,13 +83,16 @@ def tag_version_data(version_data, version_path="version.yaml"):
8283
version_data["revisionid"] = current_hash
8384
version_data["dirty"] = is_tree_dirty()
8485
version_data["dev"] = number_of_commit_since(
85-
get_version_file_path(version_path))
86+
get_version_file_path(version_path))
8687

8788
# Format the version according to pep440:
8889
pep440 = version_data["version"]
89-
if version_data.get("post"):
90+
if int(version_data.get("post", 0)) > 0:
9091
pep440 += ".post" + version_data["post"]
9192

93+
elif int(version_data.get("rc", 0)) > 0:
94+
pep440 += ".rc" + version_data["rc"]
95+
9296
if version_data.get("dev", 0):
9397
pep440 += ".dev" + str(version_data["dev"])
9498

version.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_version_file_path(version_file="version.yaml"):
3535
try:
3636
return os.path.join(subprocess.check_output(
3737
["git", "rev-parse", "--show-toplevel"], stderr=subprocess.PIPE,
38-
cwd=MY_DIR,
38+
cwd=MY_DIR,
3939
).strip(), version_file)
4040
except (OSError, subprocess.CalledProcessError):
4141
return None
@@ -76,13 +76,16 @@ def tag_version_data(version_data, version_path="version.yaml"):
7676
version_data["revisionid"] = current_hash
7777
version_data["dirty"] = is_tree_dirty()
7878
version_data["dev"] = number_of_commit_since(
79-
get_version_file_path(version_path))
79+
get_version_file_path(version_path))
8080
8181
# Format the version according to pep440:
8282
pep440 = version_data["version"]
83-
if version_data.get("post"):
83+
if int(version_data.get("post", 0)) > 0:
8484
pep440 += ".post" + version_data["post"]
8585
86+
elif int(version_data.get("rc", 0)) > 0:
87+
pep440 += ".rc" + version_data["rc"]
88+
8689
if version_data.get("dev", 0):
8790
pep440 += ".dev" + str(version_data["dev"])
8891
@@ -135,6 +138,7 @@ def escape_string(instr):
135138
def update(args):
136139
if (args.version is None and
137140
args.post is None and
141+
args.rc is None and
138142
args.codename is None):
139143
raise AttributeError("You must set something in this release.")
140144

@@ -146,6 +150,9 @@ def update(args):
146150
if args.post:
147151
version_data["post"] = args.post
148152

153+
if args.rc:
154+
version_data["rc"] = args.rc
155+
149156
if args.codename:
150157
version_data["codename"] = args.codename
151158

@@ -184,6 +191,9 @@ def main():
184191
update_parser.add_argument(
185192
"--post", help="Set to this new post release.")
186193

194+
update_parser.add_argument(
195+
"--rc", help="Set to this new release candidate.")
196+
187197
update_parser.add_argument(
188198
"--codename", help="Set to this new codename.")
189199

version.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
dependent_versions:
2+
- _version.py
23
- rekall-core/rekall/_version.py
34
- rekall-gui/_version.py
45
- tools/layout_expert/layout_expert/_version.py
56
version_data:
67
codename: Furka
7-
post: '2'
8-
version: 1.5.1
8+
post: '0'
9+
rc: '1'
10+
version: 1.5.2

0 commit comments

Comments
 (0)