I'm interested in cross-linking bug references in commit messages to a
bug tracking system. I started tinkering a couple weeks ago and am
finally understanding that committags encompass this functionality.
(From the subject line I first understood "tags" to mean git tags rather
than commit message munging.)
Is the committags idea still under active development?
I'd be happy to share what I have, which is for bug linking only, but
very little code would apply to the more general concept of committags.
Here are some ideas that might apply...
Two regexes would make it easier to configure a driver without needing
look-ahead and look-behind assertions. For example, if you want to
match non-negative integers but only in the context of a Resolves-bug
header:
Resolves-bug: 1234, 1235
With two regexes you can write:
/^Resolves-bug: \d+(, \d+)*/
/\d+/
But with only one, you'd have to write:
/(?<=^Resolves-bug: (\d+, )*)(\d+)/
The need for a lookbehind assertion means I need to stop at perlreref to
lookup syntax. Hrm... and with testing I see that it's worse than that:
$ perl -wpe 's/(?<=^Resolves-bug: (\d+, )*)(\d+)/[$2]/g'
Variable length lookbehind not implemented in regex; marked by <--
HERE in m/(?<=^Resolves-bug: (\d+, )*)(\d+) <-- HERE / at -e line 1.
I guess it can't be done even with the look-behind assertion.
I got the two-regex idea from a spec I ran across while evaluating
Subversion:
http://guest:@tortoisesvn.tigris.org/svn/tortoisesvn/trunk/doc/issuetrackers.txt
If there is interest in BTS integration beyond gitweb, for example in
git-gui, gitk, or the Windows UIs, then perhaps this spec would be worth
considering. It covers more than just hyperlinking. It also considers
issues like how to draw the form field for a bug ID as part of a commit
message form, how to validate that form field, and then how to munge the
log message to include the entered ID. Some details, like using a
newline to separate the two regexes, might be more awkward for Git than
Subversion.
I like the idea of allowing a regex writer -- a gitweb admin or a
repository owner -- to ignore issues regarding HTML escaping. For
example, I'd rather not have in the regex. And I don't want the
replacement to have to escape "&" in a query string. That's a strength
of not having to write the whole link replacement rule. And I think
hyperlinking will be one of the most common uses of this committag
feature, so it's worth special support.
In the case of false positives, it might also be helpful to have a title
attribute that explains the committag's interpretation of the text.
I also like the idea of giving the admin full control to specify a Perl
function of some sort, which might go as far as looking up bug summaries
for the "title" attribute or adding JS to fetch it via AJAX on
mouse-over. But I doubt I would bother with that myself.
Appealing as it is, the use of '$1' in my replacements didn't work for me:
$ perl -wpe '$reg = "(\\d+)"; $rep = ".\$1."; s/$reg/$rep/g'
123
.$1.
I think usage of capturing parenthesis is important, even with two
regexes, because it makes it easier to specify link text that's broader
than the data that goes in the URL. Specifically, I wanted to be able
to produce HTML like this, with the hash mark hyperlinked but not used
in the URL:
<a href="...bug=123">#123</a>
I guess that's just my aesthetic. To support that, my code calls
sprintf with $&, $1, $2, ... $9, and that particualr replacement URL
uses %2$s.
I'm concerned about the composition of these committag drivers. In
other words, will it be hard for the configurer to manage interactions
between committag drivers? To choose a sane order, will I have to
understand the implementation details of each committag driver?
Perhaps a simpler alternative would be to let at most one driver process
a given snippet of text, forbidding nesting of replacements. (If I
understand Junio's suggestion to use a list of strings and refs,
non-nesting overlaps are already not supported.) If all replacements
were hyperlinks -- and I expect that to be the common case -- they
wouldn't be nestable anyway. I wouldn't see it as a huge loss for the
nesting examples I can think of: Separate rules for span around S-o-b
and linking or obfuscation of email could be combined into one... A
rule to shade text quoted email-style with leading angle brackets could
just clobber any further processing of that text. And it might simplify
the code and testing of it quite a bit.
If committags do turn out to support nesting, perhaps it would make
sense to stratify the ordering so that it's clear whether a particular
driver takes as input HTML vs. text and outputs HTML vs. text. (For
example, weak email obfuscation might be text -> text.) I guess to
strictly honor the input and output types of a driver, the text -> html
drivers still have to be expanded in a single pass.
A few ideas for drivers that I don't think have been mentioned yet:
* Wiki page names, like to [[Feature Documentation]]. These are notable
because they tend to contain punctuation that get HTML-escaped, like
quotes and ampersands.
* Links to gitweb itself, such as 123abc:file.txt and HEAD:file.txt. I
guess the current hash linking sort of does the first case except that
you have to get the hash of the blob instead of using the commit hash,
and the current hash linking wouldn't reveal the filename until after
you click, nor when viewing textual log messages. I'm not sure whether
special support for linking to multi-commit diffs or other object types
would be as helpful.
Marcel
Jakub Narebski wrote:
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html| Jens Axboe | Re: [BUG] New Kernel Bugs |
| KAMEZAWA Hiroyuki | Re: 2.6.24-rc3-mm1 |
| Ingo Molnar | Re: [Announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS] |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Jarek Poplawski | Re: Data corruption issue with splice() on 2.6.27.10 |
| Patrick McHardy | Re: [GIT]: Networking |
