Skip to content

Commit

Permalink
ARROW-6915: [Developer] Do not overwrite point release fix versions w…
Browse files Browse the repository at this point in the history
…ith merge tool

Many times it has happened that a manually set Fix Version for a patch release got overwritten by the default behavior of the merge tool (which sets the Fix Version to the next major / non-patch release by default), and someone has had to go back and manually add the patch release version again. This ensure that the merge tool does not do this to save maintainers time and effort

Closes #6708 from wesm/ARROW-6915

Authored-by: Wes McKinney <wesm+git@apache.org>
Signed-off-by: Wes McKinney <wesm+git@apache.org>
  • Loading branch information
wesm committed Mar 25, 2020
1 parent cd33bbb commit 28bd4da
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 21 deletions.
14 changes: 14 additions & 0 deletions dev/merge_arrow_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def __init__(self, jira_con, jira_id, project, cmd):
except Exception as e:
self.cmd.fail("ASF JIRA could not find %s\n%s" % (jira_id, e))

@property
def current_fix_versions(self):
return self.issue.fields.fixVersions

def get_candidate_fix_versions(self, merge_branches=('master',)):
# Only suggest versions starting with a number, like 0.x but not JS-0.x
all_versions = self.jira_con.project_versions(self.project)
Expand Down Expand Up @@ -193,6 +197,16 @@ def resolve(self, fix_versions, comment):

resolve = [x for x in self.jira_con.transitions(self.jira_id)
if x['name'] == "Resolve Issue"][0]

# ARROW-6915: do not overwrite existing fix versions corresponding to
# point releases
fix_versions = list(fix_versions)
fix_version_names = set(x['name'] for x in fix_versions)
for version in self.current_fix_versions:
major, minor, patch = version.name.split('.')
if patch != '0' and version.name not in fix_version_names:
fix_versions.append(version.raw)

self.jira_con.transition_issue(self.jira_id, resolve["id"],
comment=comment,
fixVersions=fix_versions)
Expand Down
86 changes: 65 additions & 21 deletions dev/test_merge_arrow_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,38 @@

FakeIssue = namedtuple('issue', ['fields'])
FakeFields = namedtuple('fields', ['status', 'summary', 'assignee',
'components'])
'components', 'fixVersions'])
FakeAssignee = namedtuple('assignee', ['displayName'])
FakeStatus = namedtuple('status', ['name'])
FakeComponent = namedtuple('component', ['name'])
FakeProjectVersion = namedtuple('version', ['name', 'raw'])
FakeVersion = namedtuple('version', ['name', 'raw'])

RAW_VERSION_JSON = [
{'version': 'JS-0.4.0', 'released': False},
{'version': '0.11.0', 'released': False},
{'version': '0.12.0', 'released': False},
{'version': '0.10.0', 'released': True},
{'version': '0.9.0', 'released': True}
{'name': 'JS-0.4.0', 'released': False},
{'name': '0.11.0', 'released': False},
{'name': '0.12.0', 'released': False},
{'name': '0.10.0', 'released': True},
{'name': '0.9.0', 'released': True}
]


SOURCE_VERSIONS = [FakeProjectVersion(raw['version'], raw)
SOURCE_VERSIONS = [FakeVersion(raw['name'], raw)
for raw in RAW_VERSION_JSON]

TRANSITIONS = [{'name': 'Resolve Issue', 'id': 1}]

jira_id = 'ARROW-1234'
status = FakeStatus('In Progress')
fields = FakeFields(status, 'issue summary', FakeAssignee('groundhog'),
[FakeComponent('C++'), FakeComponent('Format')])
[FakeComponent('C++'), FakeComponent('Format')],
[])
FAKE_ISSUE_1 = FakeIssue(fields)


class FakeJIRA:

def __init__(self, issue=None, project_versions=None, transitions=None):
def __init__(self, issue=None, project_versions=None, transitions=None,
current_fix_versions=None):
self._issue = issue
self._project_versions = project_versions
self._transitions = transitions
Expand Down Expand Up @@ -109,12 +111,11 @@ def test_jira_fix_versions():

def test_jira_no_suggest_patch_release():
versions_json = [
{'version': '0.11.1', 'released': False},
{'version': '0.12.0', 'released': False},
{'name': '0.11.1', 'released': False},
{'name': '0.12.0', 'released': False},
]

versions = [FakeProjectVersion(raw['version'], raw)
for raw in versions_json]
versions = [FakeVersion(raw['name'], raw) for raw in versions_json]

jira = FakeJIRA(project_versions=versions, transitions=TRANSITIONS)
issue = merge_arrow_pr.JiraIssue(jira, 'ARROW-1234', 'ARROW', FakeCLI())
Expand All @@ -126,14 +127,14 @@ def test_jira_no_suggest_patch_release():
def test_jira_parquet_no_suggest_non_cpp():
# ARROW-7351
versions_json = [
{'version': 'cpp-1.5.0', 'released': True},
{'version': 'cpp-1.6.0', 'released': False},
{'version': 'cpp-1.7.0', 'released': False},
{'version': '1.11.0', 'released': False},
{'version': '1.12.0', 'released': False}
{'name': 'cpp-1.5.0', 'released': True},
{'name': 'cpp-1.6.0', 'released': False},
{'name': 'cpp-1.7.0', 'released': False},
{'name': '1.11.0', 'released': False},
{'name': '1.12.0', 'released': False}
]

versions = [FakeProjectVersion(raw['version'], raw)
versions = [FakeVersion(raw['name'], raw)
for raw in versions_json]

jira = FakeJIRA(project_versions=versions, transitions=TRANSITIONS)
Expand Down Expand Up @@ -231,7 +232,7 @@ def test_multiple_authors_bad_input():
def test_jira_already_resolved():
status = FakeStatus('Resolved')
fields = FakeFields(status, 'issue summary', FakeAssignee('groundhog'),
[FakeComponent('Java')])
[FakeComponent('Java')], [])
issue = FakeIssue(fields)

jira = FakeJIRA(issue=issue,
Expand All @@ -246,6 +247,49 @@ def test_jira_already_resolved():
issue.resolve(fix_versions, "")


def test_no_unset_point_release_fix_version():
# ARROW-6915: We have had the problem of issues marked with a point release
# having their fix versions overwritten by the merge tool. This verifies
# that existing patch release versions are carried over
status = FakeStatus('In Progress')

versions_json = {
'0.14.2': {'name': '0.14.2', 'id': 1},
'0.15.1': {'name': '0.15.1', 'id': 2},
'0.16.0': {'name': '0.16.0', 'id': 3},
'0.17.0': {'name': '0.17.0', 'id': 4}
}

fields = FakeFields(status, 'summary', FakeAssignee('someone'),
[FakeComponent('Java')],
[FakeVersion(v, versions_json[v])
for v in ['0.17.0', '0.15.1', '0.14.2']])
issue = FakeIssue(fields)

jira = FakeJIRA(issue=issue, project_versions=SOURCE_VERSIONS,
transitions=TRANSITIONS)

issue = merge_arrow_pr.JiraIssue(jira, 'ARROW-1234', 'ARROW', FakeCLI())
issue.resolve([versions_json['0.16.0']], "a comment")

assert jira.captured_transition == {
'jira_id': 'ARROW-1234',
'transition_id': 1,
'comment': 'a comment',
'fixVersions': [versions_json[v]
for v in ['0.16.0', '0.15.1', '0.14.2']]
}

issue.resolve([versions_json['0.15.1']], "a comment")

assert jira.captured_transition == {
'jira_id': 'ARROW-1234',
'transition_id': 1,
'comment': 'a comment',
'fixVersions': [versions_json[v] for v in ['0.15.1', '0.14.2']]
}


def test_jira_output_no_components():
# ARROW-5472
status = 'Interesting work'
Expand Down

0 comments on commit 28bd4da

Please sign in to comment.