alexcorre / git-blame

Plugin for Atom Editor. Toggle git-blame annotations for the current file in the gutter.
MIT License
98 stars 58 forks source link

Make custom url template per-repo / project / folder #18

Open dougborg opened 10 years ago

dougborg commented 10 years ago

I interact with git repositories from multiple places (GitHub, BitBucket, internal Stash repositories, etc.). Would it be possible to make the custom commit url template string setting per-project? One idea would be to read a custom git configuration property set in the local repository's .git/config file.

alexcorre commented 10 years ago

I was thinking of doing something like this at some point but never quite figured out how it should work. This issue can be a discussion on how to best solve the per project.

Ideally this thing should work with as many remote repositories out of the box as possible automatically, by parsing the remote url, as I've done for github and bitbucket. I was hoping if another remote repo tool was useful to someone they'd send a pull request with support for it. This could solve many of the common remotes and Stash repos.

What are the specific cases that url parsing cannot solve?

I like the custom git config that is local to the repository but have a few open questions:

dougborg commented 10 years ago

Acutally, I figured out this is not actually a real big problem for me. I took a look at the code and I like they way it automatically detects the github and bitbucket repos and then falls back on the custom parser. I was able to figure out the stash format so I think that will be fine. This is the template that works for our Stash repo:

https://stash.company.com/projects/<%- project %>/repos/<%- repo %>/commits/<%- revision %>

It may still be worthwhile to have per-repo configs for the template URL, but it doesn't look like it is actually needed to solve my use case. My take on your open questions:

  1. I don't think there is any way to make the template URL setting portable across clones of a repo. As far as I know Git doesn't have any facility for inheriting configuration from the "origin" repo. That would be cool though! There is system and user-level configs, and I think you would get that level of inheritance "for free" if you read a custom configuration property from git.
  2. I would think the key pairing for a config could be something like:
git config atom.git-blame.customtemplateurl "https://stash.company.com/projects/<%- project %>/repos/<%- repo %>/commits/<%- revision %>"

That would enter something like:

[atom "git-blame"]
    customtemplateurl = https://stash.company.com/projects/<%- project %>/repos/<%- repo %>/commits/<%- revision %>