From 9707978bc9fcbb7c8c26f1993507ac22c1de3535 Mon Sep 17 00:00:00 2001 From: sidpremkumar Date: Sep 18 2019 22:11:50 +0000 Subject: Removing date from upstream status in JIRA description --- diff --git a/sync2jira/downstream.py b/sync2jira/downstream.py index 250cd11..5af55c7 100644 --- a/sync2jira/downstream.py +++ b/sync2jira/downstream.py @@ -710,25 +710,40 @@ def _update_transition(client, existing, issue): """ # Update the issue status in the JIRA description # Format the status - today = datetime.today() - formatted_status = "[%s] Upstream issue status: %s" % ( - today.strftime("%a %b %y"), issue.status) + formatted_status = "Upstream issue status: %s" % issue.status new_description = existing.fields.description + # Bool to indicate if we should update + update = False # Check if the issue has the issue status line + # First check legacy upstream status so we can update them if "] Upstream issue status:" in existing.fields.description: # Use pattern matching to find and update the status new_description = re.sub( r"\[.*\] Upstream issue status: .*", formatted_status, new_description) + update = True + # Now check if the status is already present + elif formatted_status in existing.fields.description: + pass + # Then check for upstream status + elif "Upstream issue status:" in existing.fields.description: + # Use pattern matching to find and update the status + new_description = re.sub( + r"Upstream issue status: .*", + formatted_status, + new_description) + update = True else: # We can just add this line to the very top new_description = formatted_status + '\n' + new_description - # Now we can update the JIRA issue (always need to update this - # as there is a timestamp involved) - data = {'description': new_description} - existing.update(data) - log.info(' Updated transition') + update = True + if update: + # Now we can update the JIRA issue (always need to update this + # as there is a timestamp involved) + data = {'description': new_description} + existing.update(data) + log.info(' Updated transition') # If the user just inputted True, only update the description # If the user added a custom closed status, attempt to close the