Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions docs/source/config-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ The config file is made up of multiple parts

* You can add your projects here. The :code:`'project'` field is associated
with downstream JIRA projects, and :code:`'component'` with downstream
components. You can add the following to the :code:`issue_updates` array:
components. You can add the following to the :code:`issue_updates` array:

* :code:`'comments'`
* Sync comments and comment edits
Expand All @@ -127,8 +127,8 @@ The config file is made up of multiple parts
* :code:`{'assignee': {'overwrite': True/False}}`
* Sync assignee (for Github only the first assignee will sync) do/don't overwrite downstream assignee
* Note that the downstream assignee is selected by performing an LDAP query for the upstream user in the
"Professional Social Media" link in the RoverPeople profiles, so, in order for this feature to work properly, each
potential assignee needs to ensure that they have added their upstream identity(es) to their Rover profile.
"Professional Social Media" link in the RoverPeople profiles, so, in order for this feature to work properly,
each potential assignee needs to ensure that they have added their upstream identity(es) to their Rover profile.
* :code:`'description'`
* Sync description
* :code:`'title'`
Expand All @@ -140,11 +140,13 @@ potential assignee needs to ensure that they have added their upstream identity(
* :code:`github_markdown`
* If description syncing is turned on, this flag will convert Github markdown to Jira syntax. This uses the pypandoc module.
* :code:`upstream_id`
* If selected this will add a comment to all newly created JIRA issue in the format 'UPSTREAM_PROJECT-#1' where the number indicates the issue ID. This allows users to search for the issue on JIRA via the issue number.
* If selected this will add a comment to all newly created JIRA issue in the format 'UPSTREAM_PROJECT-#1' where
the number indicates the issue ID. This allows users to search for the issue on JIRA via the issue number.
* :code:`url`
* This flag will add the upstream url to the bottom of the JIRA ticket
* :code:`github_project_number`
* Specify the GitHub project number. If specified, story points and priority will be selected from this project, and other projects linked to the issues will be ignored.
* Specify the GitHub project number. If specified, story points and priority will be selected from this project,
and other projects linked to the issues will be ignored.
* :code:`github_project_fields`
* Sync GitHub projects fields. e.g, storypoints, priority

Expand All @@ -153,21 +155,24 @@ potential assignee needs to ensure that they have added their upstream identity(
:Overwrite: Setting this to :code:`True` will ensure that Upstream (GitHub) values will overwrite downstream ones (i.e. if its empty upstream it'll be empty downstream)
:CUSTOM_TRANSITION: Setting this value will get Sync2Jira to automatically transition downstream tickets once their upstream counterparts get closed. Set this to whatever 'closed' means downstream.

* You can add your projects here. The 'project' field is associated with downstream JIRA projects, and 'component' with downstream components
You can add the following to the :code:`pr_updates` array:
* You can add your projects here. The 'project' field is associated with downstream JIRA projects, and 'component' with
downstream components. You can add the following to the :code:`pr_updates` array:

* :code:`{'merge_transition': 'CUSTOM_TRANSITION'}`
* Sync when upstream PR gets merged. Attempts to transition JIRA ticket to CUSTOM_TRANSITION on upstream merge
* :code:`{'link_transition': 'CUSTOM_TRANSITION'}`
* Sync when upstream PR gets linked. Attempts to transition JIRA ticket to CUSTOM_TRANSITION on upstream link

* You can add the following to the mapping array. This array will map an upstream field to the downstream counterpart with XXX replaced.
* You can add the following to the mapping array. This array will map an upstream field to the downstream counterpart
with XXX replaced.

* :code:`{'fixVersion': 'Test XXX'}`
* Maps upstream milestone (suppose it's called 'milestone') to downstream fixVersion with a mapping (for our example it would be 'Test milestone')
* Maps upstream milestone (suppose it's called 'milestone') to downstream fixVersion with a mapping (for our
example it would be 'Test milestone')

* It is strongly encouraged for teams to use the :code:`owner` field. If configured, owners will be alerted if Sync2Jira finds duplicate downstream issues.
Further the owner will be used as a default in case the program is unable to find a valid assignee.
* It is strongly encouraged for teams to use the :code:`owner` field. If configured, owners will be alerted if Sync2Jira
finds duplicate downstream issues. Further the owner will be used as a default in case the program is unable to find a
valid assignee.

.. code-block:: python

Expand Down
5 changes: 2 additions & 3 deletions sync2jira/downstream_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def _update_jira_issue(existing, issue, client, config):
# and when the issue is closed.
if issue.status == "Closed":
log.info("Attempting to update downstream issue on upstream closed event")
_update_on_close(existing, issue, updates)
_update_on_close(existing, updates)

log.info("Done updating %s!", issue.url)

Expand Down Expand Up @@ -1108,7 +1108,7 @@ def _update_description(existing, issue):
UPDATE_ENTRY = Union[str, dict[str, Union[str, dict[str, Any]]]]


def _update_on_close(existing, issue, updates: list[UPDATE_ENTRY]):
def _update_on_close(existing, updates: list[UPDATE_ENTRY]):
"""Update downstream Jira issue when upstream issue was closed

Example update configuration:
Expand All @@ -1127,7 +1127,6 @@ def _update_on_close(existing, issue, updates: list[UPDATE_ENTRY]):
]

:param jira.resource.Issue existing: existing Jira issue
:param sync2jira.intermediary.Issue issue: Upstream issue
:param dict updates: update configuration
:return: None
"""
Expand Down
12 changes: 4 additions & 8 deletions tests/test_downstream_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,11 +1548,10 @@ def test_update_on_close_update(self):
"""
# Set up return values
self.mock_downstream.fields.description = ""
self.mock_issue.status = "Closed"
updates = [{"on_close": {"apply_labels": ["closed-upstream"]}}]

# Call the function
d._update_on_close(self.mock_downstream, self.mock_issue, updates)
d._update_on_close(self.mock_downstream, updates)

# Assert everything was called correctly
self.mock_downstream.update.assert_called_with(
Expand All @@ -1565,11 +1564,10 @@ def test_update_on_close_no_change(self):
"apply_labels" configuration but there is no update required.
"""
# Set up return values
self.mock_issue.status = "Closed"
updates = [{"on_close": {"apply_labels": ["tag4"]}}]

# Call the function
d._update_on_close(self.mock_downstream, self.mock_issue, updates)
d._update_on_close(self.mock_downstream, updates)

# Assert everything was called correctly
self.mock_downstream.update.assert_not_called()
Expand All @@ -1580,11 +1578,10 @@ def test_update_on_close_no_action(self):
"apply_labels" configuration.
"""
# Set up return values
self.mock_issue.status = "Closed"
updates = [{"on_close": {"some_other_action": None}}]

# Call the function
d._update_on_close(self.mock_downstream, self.mock_issue, updates)
d._update_on_close(self.mock_downstream, updates)

# Assert everything was called correctly
self.mock_downstream.update.assert_not_called()
Expand All @@ -1595,11 +1592,10 @@ def test_update_on_close_no_config(self):
configuration for close events.
"""
# Set up return values
self.mock_issue.status = "Closed"
updates = ["description"]

# Call the function
d._update_on_close(self.mock_downstream, self.mock_issue, updates)
d._update_on_close(self.mock_downstream, updates)

# Assert everything was called correctly
self.mock_downstream.update.assert_not_called()
Expand Down