#107 Removing date from upstream status in JIRA description
Merged 4 years ago by sidpremkumar. Opened 4 years ago by sidpremkumar.
sidpremkumar/sync-to-jira remove-date-from-transition-status  into  develop

file modified
+23 -8
@@ -710,25 +710,40 @@ 

      """

      # 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

Removing date from upstream status in JIRA
[Wed Sep 15] Upstream Issue Status: Open -> Upstream Issue Status: Open

@ralph Could you take a look at this solution to issue #106

rebased onto cbc542915485dcbfeb50f9c6e85c11652bbae7e8

4 years ago

I suggest that any kind of metadata, including the upstream issue status, would go into labels - because the ticket content is unstructured data and metadata by definition is.
This has few advantages:
1. that issue data remains exactly the same
2. easy to read, no funny lines with brackets or any other additions - the ticket looks almost the same as the github one
3. easy searching- if you want to look for 'upstream open issues' you can search on the labels, way cheaper then looking for all tickets data.
4. maybe in the future we can write a plugin for jira to handle those syncs, for example something that will more nicely track the github ticket - it will be very easy then to use the labels for doing so.

Roy, I think that's a pretty good idea.

When this was written the very first time around, we used the upstream issue url in the description as the kind of "primary key" identifier to track which jira issues were managed by sync2jira and which were not. This was super error prone, and early on we moved to use jira remote links for that. Your suggestion would build on that into a more general pattern.

It's a fair bit of work though and Sid has limited time, so I'd suggest splitting it into a separate work item here.

Two questions about the current code change here:

  • Sid, if merged, will this update the descriptions on all managed jira issues (spamming people a bit)?
  • Roy, would this be a nice to have change for you on its own, without the label refactoring? Or, would you rather wait to see everything move to labels?

@ralph Yes this would update the description of all issue but this would ensure that there aren't any more 'phantom' updates (i.e. no more random updates as the date changes).

Personally, although I see what @rgolan is saying I believe that not all teams would benefit from this. Having the issue status, description etc all neatly formatted in the JIRA ticket makes it a lot easier to read and manage issues on JIRA. I suggested to Roy that it might make more sense to add another field to the updates array that would sync upstream status with downstream labels. That way Roys team can utilize labels being synced without disrupting other teams. WDYT?

Either way, I believe that this PR will benefit all teams as Roy pointed out the phantom updates disrupt the history of the JIRA issue.

Makes sense. :+1: for the change as it is.

As for optional additional syncing of labels, let's take it up in another issue. It seems like a nice-to-have, not something urgent so it can probably be prioritized behind other work that may have a higher impact (like Jetrics? Dunno.)

Works for me :thumbsup: . @rgolan we'll move ahead with this change to remove the phantom updates and then if you want to add label syncing upstream status (i.e. 'Open'/'Closed' in the JIRA issue) could you please submit an issue here? Does that work?

Looks good to me - I'll open a separate ticket for managing metadata

rebased onto 9707978

4 years ago

Pull-Request has been merged by sidpremkumar

4 years ago
Metadata