Skip to content

Commit 27f5664

Browse files
committed
Do not suggest setting Fix Version for patch releases by default
1 parent 747b476 commit 27f5664

3 files changed

Lines changed: 54 additions & 36 deletions

File tree

ci/travis_lint.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ set -ex
2323
export ARROW_TRAVIS_USE_TOOLCHAIN=0
2424
source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh
2525

26-
pip install pre_commit
26+
pip install pre_commit cmake_format==0.5.2 pytest
2727
pre-commit install
2828

2929
# TODO: Move more checks into pre-commit as this gives a nice summary
3030
# and doesn't abort on the first failed check.
3131
pre-commit run hadolint -a
3232

3333
# CMake formatting check
34-
pip install cmake_format==0.5.2
3534
$TRAVIS_BUILD_DIR/run-cmake-format.py --check
3635

3736
# C++ code linting
@@ -54,7 +53,10 @@ FLAKE8="python3 -m flake8"
5453
python3 -m pip install -q flake8
5554

5655
if [ "$ARROW_CI_DEV_AFFECTED" != "0" ]; then
57-
$FLAKE8 --count $ARROW_DEV_DIR
56+
pushd $ARROW_DEV_DIR
57+
$FLAKE8 --count .
58+
py.test test_merge_arrow_pr.py
59+
popd
5860
fi
5961

6062
if [ "$ARROW_CI_INTEGRATION_AFFECTED" != "0" ]; then

dev/merge_arrow_pr.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,20 @@ def get_candidate_fix_versions(self, merge_branches=('master',)):
160160
mainline_versions = [x for x in unreleased_versions
161161
if mainline_version_regex.match(x.name)]
162162

163+
mainline_non_patch_versions = []
164+
for v in mainline_versions:
165+
(major, minor, patch) = v.name.split(".")
166+
if patch == "0":
167+
mainline_non_patch_versions.append(v)
168+
169+
if len(mainline_versions) > len(mainline_non_patch_versions):
170+
# If there is a non-patch release, suggest that instead
171+
mainline_versions = mainline_non_patch_versions
172+
163173
default_fix_versions = [
164174
fix_version_from_branch(x, mainline_versions).name
165175
for x in merge_branches]
166176

167-
for v in default_fix_versions:
168-
# Handles the case where we have forked a release branch but not
169-
# yet made the release. In this case, if the PR is committed to
170-
# the master branch and the release branch, we only consider the
171-
# release branch to be the fix version. E.g. it is not valid to
172-
# have both 1.1.0 and 1.0.0 as fix versions.
173-
(major, minor, patch) = v.split(".")
174-
if patch == "0":
175-
previous = "%s.%s.%s" % (major, int(minor) - 1, 0)
176-
if previous in default_fix_versions:
177-
default_fix_versions = [x for x in default_fix_versions
178-
if x != v]
179-
180177
return all_versions, default_fix_versions
181178

182179
def resolve(self, fix_versions, comment):
@@ -200,26 +197,29 @@ def resolve(self, fix_versions, comment):
200197

201198
def show(self):
202199
fields = self.issue.fields
200+
print(format_jira_output(self.jira_id, fields.status.name,
201+
fields.summary, fields.assignee,
202+
fields.components))
203203

204-
assignee = fields.assignee
205-
if assignee is None:
206-
assignee = "NOT ASSIGNED!!!"
207-
else:
208-
assignee = assignee.displayName
209204

210-
components = fields.components
211-
if len(components) == 0:
212-
components = 'NO COMPONENTS!!!'
213-
else:
214-
components = ', '.join((x.name for x in components))
215-
216-
print("=== JIRA {} ===".format(self.jira_id))
217-
print("Summary\t\t{}".format(fields.summary))
218-
print("Assignee\t{}".format(assignee))
219-
print("Components\t{}".format(components))
220-
print("Status\t\t{}".format(fields.status.name))
221-
print("URL\t\t{}/{}".format('/'.join((JIRA_API_BASE, 'browse')),
222-
self.jira_id))
205+
def format_jira_output(jira_id, status, summary, assignee, components):
206+
if assignee is None:
207+
assignee = "NOT ASSIGNED!!!"
208+
else:
209+
assignee = assignee.displayName
210+
211+
if len(components) == 0:
212+
components = 'NO COMPONENTS!!!'
213+
else:
214+
components = ', '.join((x.name for x in components))
215+
216+
return """=== JIRA {} ===
217+
Summary\t\t{}
218+
Assignee\t{}
219+
Components\t{}
220+
Status\t\t{}
221+
URL\t\t{}/{}""".format(jira_id, summary, assignee, components, status,
222+
'/'.join((JIRA_API_BASE, 'browse')), jira_id)
223223

224224

225225
class GitHubAPI(object):

dev/test_merge_arrow_pr.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ def test_jira_fix_versions():
107107
assert default_versions == ['0.11.0']
108108

109109

110+
def test_jira_no_suggest_patch_release():
111+
versions_json = [
112+
{'version': '0.11.1', 'released': False},
113+
{'version': '0.12.0', 'released': False},
114+
]
115+
116+
versions = [FakeProjectVersion(raw['version'], raw)
117+
for raw in versions_json]
118+
119+
jira = FakeJIRA(project_versions=versions, transitions=TRANSITIONS)
120+
issue = merge_arrow_pr.JiraIssue(jira, 'ARROW-1234', 'ARROW', FakeCLI())
121+
all_versions, default_versions = issue.get_candidate_fix_versions()
122+
assert all_versions == versions
123+
assert default_versions == ['0.12.0']
124+
125+
110126
def test_jira_invalid_issue():
111127
class Mock:
112128

@@ -188,7 +204,7 @@ def test_jira_output_no_components():
188204
# ARROW-5472
189205
status = 'Interesting work'
190206
components = []
191-
output = merge_arrow_pr.format_resolved_issue_status(
207+
output = merge_arrow_pr.format_jira_output(
192208
'ARROW-1234', 'Resolved', status, FakeAssignee('Foo Bar'),
193209
components)
194210

@@ -199,7 +215,7 @@ def test_jira_output_no_components():
199215
Status\t\tResolved
200216
URL\t\thttps://issues.apache.org/jira/browse/ARROW-1234"""
201217

202-
output = merge_arrow_pr.format_resolved_issue_status(
218+
output = merge_arrow_pr.format_jira_output(
203219
'ARROW-1234', 'Resolved', status, FakeAssignee('Foo Bar'),
204220
[FakeComponent('C++'), FakeComponent('Python')])
205221

0 commit comments

Comments
 (0)