stevenharman / git_tracker

Some simple tricks that make working with Pivotal Tracker even better... and easier... um, besier!
https://github.com/stevenharman/git_tracker
MIT License
170 stars 11 forks source link

Support for other Tracking Systems #23

Open stevesparks opened 4 years ago

stevesparks commented 4 years ago

I am on a project that uses JIRA today. Their story format is XYZ-123, where XYZ is a project prefix and 123 is the story number. In my work, I would create branch sparks/xyz-123 and make all the commits prefixed thus:

[XYZ-123] Add sweet feature

I think the change that would work best would be to allow the user to specify the regex in init, eg.:

git tracker init '[A-Z]{2,5}-[0-9]{1,5}' or if they're project specific... git tracker init 'XYZ-[0-9]{1,5}'

stevenharman commented 4 years ago

I wonder if allowing arbitrary patterns is a great idea from a UX perspective? I can image even things like folks shell expansion and escaping causing all kinds of confusion. I wonder if #7 was onto something with wanting "templates" or "modes" for various tools. If we went that route, I could image something like

git tracker init --template=tracker # this is also the default option if no `--template` is specified
git tracker init --template=jira

We could then also list possible templates as part of git --help.

I think once we've gone the route of having swappable "templates" - which I think only really impacts the Branch::story_number functionality we've got the nut cracked. Then adding new templates shouldn't (🤞) be too hard. And maybe even provides a seam to add something like --pattern='XYZ-[0-9]{1,5}' for "custom" patterns.

Thoughts? 🤔

stevesparks commented 4 years ago

I had almost made that exact suggestion, but opted for the regex that was ultimately more flexible, even at the risk of having incompatibilities introduced. So, templates gets a 👍👍 from me.

axelson commented 3 years ago

I would like to be able to support asana as well (although you have to use your own asana github workflow). The main issue with that is that there is not a simple issue number, instead you get a link like https://app.asana.com/0/039346075456211/119714138891232/f which doesn't fit well in the branch name. Would it be possible to use the git branch description instead of the branch name?

Edit: I have a version of that now working here: https://github.com/axelson/git_tracker/commit/437e0b4d56468319ac64c4f582eaee58a44c1d68

Edit 2: Creating the branch with the description can be facilitated with a git alias:

git config --global alias.newbr "!f() { if [ \"\$#\" -eq 2 ]; then git checkout -b \"\$1\"; git config \"branch.\$1.description\" \"\$2\"; fi; }; f"

And then use it when creating a new branch:

git newbr fix-bug-in-foobar https://app.asana.com/0/039346075456211/119714138891232/f
stevenharman commented 3 years ago

@axelson I've not used Asana, but it sure is surprising they don't give a shorter, human-friendly, identifier that could be used. 😖

I'm not opposed to adding something like this. Given your request, and the original question about adding JIRA support, and past requests for other systems, I think from a design perspective it might be best to build this in a way that each "other system," including Tracker, are implemented as a strategy. That is, if using the Tracker strategy, it would look up the "story number" based on branch name. The JIRA strategy would also use the branch name, but match on a different pattern. The Asana strategy would look up the info (a URL) via the description, as you've suggested.

axelson commented 3 years ago

I think that approach makes sense :+1: