Open and close trac tickets with a single commit - trac

I am looking for a way to add a post-commit or pre-commit hook to my VCS that will allow me to both create and close a trac ticket in one go.
The use-case is for when a bug has been found, and corrected, but a single developer who wants to make sure the project manager can see the fix has been done, when it was done and what milestone the fix has been done in.
We have a default milestone in trac when creating a ticket, so reflecting that information would be good too.

I recommend extending TracTicketChangesetsPlugin to do this.
You would adjust the way it detects the command in the commit message (see http://trac-hacks.org/browser/tracticketchangesetsplugin/trunk/ticketchangesets/commit_updater.py?rev=8114#L154), as you would not have a ticket number to refer to yet.
See http://trac-hacks.org/browser/tracticketchangesetsplugin/trunk/ticketchangesets/commit_updater.py?rev=8114#L215 for where it actually does the parsing. You would have to return some new token to represent "new ticket."
The code that actually changes the tickets is at http://trac-hacks.org/browser/tracticketchangesetsplugin/trunk/ticketchangesets/commit_updater.py?rev=8114#L234 , so here would you create NEW ticket, then close it straight away. To create a new ticket, call Ticket(self.env) and then save it with Ticket.insert() (see http://trac.edgewall.org/browser/trunk/trac/ticket/model.py?rev=9692#L174 ).
If you do this, I recommend attaching your patch to a new ticket at Trac Hacks.

Create a post-commit hook. Notice how the trac post-commit hooks work and copy this functionality to control this action (creation + closing ticket). The creation + closing are two separate http requests that can happen with wget, you can intercept the ticket creation form's post, look at how the existing trac integration works, or hack it some other way. Have fun. I wish this could be more specific but it really does depend on what you're trying to do.

Related

What is the process for changing the "lead owner" through the salesforce API?

Currently creating an automation using zapier which should change the lead owner in salesforce when the event takes place. It successfully reaches salesforce but does not actually change the "lead owner" but it is instead reflected in the lead history section. There is no clear salesforce workflow or rule in place which should prevent this automation from occurring.
When the automation executes as you can see above, the lead owner successfully changes in the lead history but it does not actually change the lead owner of the actual lead so we are manually having to go back and change this.
Has anybody else faced similar issues when working with the salesforce API when changing the lead owner and if so what was the solution?
Check Lead assignment rules. It's separate area in Setup, different from workflows, flows, process builder and triggers.
You probably have an active rule that runs on update, not only on insert. Your API call works OK, changes the OwnerId field but then the assignment rule overwrites that. That's why you see it as 2 entries in history.
You can also confirm what's going on byenabling debug logging on the integration user and check if it captures anything.
Optionally you could also suppress the assignment rule during the update. This is... questionable. I mean talk with your SF admin first, if you suppress the rule then you moved bit of logic out of salesforce. 2 months later nobody will remember why something doesn't fire, it's cleaner to just modify the rule to skip these records.
If Zapier uses SF REST API there's a HTTP header it should send, Sforce-Auto-Assign: FALSE. If it uses SOAP API - similar thing will have to be set in the SOAP message's header, check the WSDL for exact syntax?
We solved this, just broke down the issue and resolved by doing the following (This was beyond the standard salesforce scope of support as we use custom prefill URL's for anybody wondering):
Create a new hidden field called something such as 'tmp_owner'
Assign the new lead owner ID to a new text field called 'tmp_owner' which is hidden on
the lead field to other salesforce org users
Added a salesforce workflow rule when this 'tmp_owner' is populated replace the 'lead owner' field with the data.

Bitbucket - Add default task when creating a pull requst

I am looking into improving the workflow my colleague and myself are using for BitBucket. Something that is often forgotten is the documentation for the feature we are working on therefore I thought I good way to 'don't forget' would be to add a Task as soon as a Pull request is created for a particular branch.
The first think a developer should do after creating the Pull Request would be:
- Add a comment, something like WIP (Work in Progress)
- Create a task underneath, something like 'Add documentation'
In this way, we won't be able to 'Merge' the branch into 'Develop' if All tasks are not completed (this is how it is currenly configured).
Rather than having the developer to do so, it would be good if we can have the system to do so as soon as we create the Pull Request.
Is that possible?
I had searchd on Internet, to be honest I didn't understand if taht functionality comes with like the Premium package or if it is an Add-On...who knows.
Thanks :)
Atlassian recently added a 'Default Pull Request Tasks' feature to Bitbucket Cloud.
The same functionality was previously available as a Bitbucket app, but it was removed in May 2020. It's now a native feature.
Product announcement: https://bitbucket.org/blog/bitbucket-cloud-product-updates-august-2022
Feature details: https://bitbucket.org/blog/default-pull-request-tasks
You can try this. It is free for 30 days.
https://marketplace.atlassian.com/apps/1225598/default-tasks-for-pull-requests?tab=pricing&hosting=datacenter
I did not find any free solutions.

How can I prevent overwriting changes to a ticket that was recently updated?

If I make an edit to a Trac ticket, but someone beat me to it, this message is displayed:
Ideally, I would read this message and figure out what I can overwrite and what I should not. But, depending on this message to keep users from overwriting what was submitted is not something that we should depend on:
This may sound a little harsh, but you'll see, when you do usability tests, that there are quite a few users who simply do not read words that you put on the screen. If you pop up an error box of any sort, they simply will not read it.
Is there a better way to prevent these overwrites in Trac - e.g., if a ticket has been modified while you were modifying it, you must refresh the page, etc?
Yes, if the server would send the page modified outside and if the javascript running in your browser could merge that into your local changes. But noone has implemented it in the current trac.

Edgewall Trac: retrospectives of notifications

Hello,
is it possible at all to include not only the status and most recent comment in messages sent on ticket creation and ticket changes? I'd like to see much more, say all available retrospective information, that is the entire Change history.
Maybe someone already configured Trac this way. If so, I'd be very grateful for information about that configuration, including the Trac version used with that application.
Cheers,
Thx
Trac has change listener interfaces for binding modules to act on changes, i.e. notify on ticket change. See the Trac wiki documentation for descriptions of the I***ChangeListener extension points available by now.
But you'll notice, that the data provided by these interfaces provide only limited information about the changed resource, such as ID and the changed/old vs. new values. So your request can't be solved at all by configuration alone.
While it might be possible to do more complete notification by coding look-ups for additional data in the Trac db, even this isn't possible under all circumstances. Think i.e. about ticket deletion, where everything already has gone when the change listeners are fired with the pre-defined information.

suggestions for Rails back-end workflow for cleaning up attachments to abandoned drafts?

I'm working on a Rails application. Two of my models are notes and attachments. The user can create notes and add attachments to them. This is standard stuff and I already have this working fine.
Currently, the user must create a note before they can add attachments to it. I'm looking to implement a more streamlined workflow for the user, similar to the familiar email workflow where you can add attachments to an unsaved email. However, the key is that I don't want the user to even have to save a draft of the note before the attachment can be added, and I want this unsaved note to be abandoned if the user navigates away (I don't want to have the additional complexity of unsaved/unpublished notes).
I know that when the note hasn't initially been saved yet, I can create the attachments without the link to the note, and then establish the link when the note gets saved. The part I'm drawing a blank on is how do I remove the unused attachments if the user breaks off the note creation process? Is there a hook that I'm missing that allows me to see that the user broke off?
Without such a hook, the first solution that comes to mind is a nightly cleanup script that runs via cron that would find all of the unattached attachments and remove them (perhaps filtering by attachments that have been created more than 24 hours ago). Is this the best solution?
There really isn't any kind of trigger to let you know when to clean those up, since a user can just leave the site without "logging out" or some other action. So that leaves you with a background job not attached to user action. In your case I think a nightly cron is nice and simple and would fit this situation well.