monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] Re: invalid author and committer values produced by git


From: Derek Scherger
Subject: [Monotone-devel] Re: invalid author and committer values produced by git export
Date: Mon, 15 Feb 2010 23:33:42 -0700


On Wed, Jan 6, 2010 at 10:36 PM, Derek Scherger <address@hidden> wrote:
http://savannah.nongnu.org/bugs/?28372

Apparently author names that don't match the "Name <email>" format are imported ok by git but the resulting repo has some sort of problems, although I don't have any details on the nature of the problems.

Currently we grab both the value of the author cert and the key that signed the author cert. The value is to be used as the git author and the key name is to be used as the git committer. Both of these are looked up in the author map to see if the user has specified replacement values that should be used in the exported data. If no replacements have been specified both the author and committer are checked to see if they contain '<' and '>' characters and if neither are present they are wrapped in these characters. This produces names that lack the "Name " before the "<email>" and apparently causes problems.

If I remember right, there was once some interest in an option to require these values to exist in the author map file avoiding any automated doctoring of the author and committer values or failing if unmapped values exist. Having this might be one way to deal with the above problem. Reasonable suggestions for what to call such an option are welcome. I can't think of anything catchy.

Another solution is to do more comprehensive checks on the author and committer values if they don't exist in the author map file, such as the following:

If the value doesn't contain < and > characters
- replace "foo" with "foo <foo>" if no "@" character exists
- replace "address@hidden" with "foo <address@hidden>"

If the value begins with  '<' and ends with '>'
- replace "<foo>" with "foo <foo>" if no "@" character exists
- replace "<address@hidden>" with "foo <address@hidden>"

Maybe these adjustments should be done in a lua hook that can be customized if needed.

Finally, ensure that the resulting values match a valid git name regex, something like "^[^<]* <[^>]*>$" and fail if they don't. This could check values coming from the author map in addition to values constructed by the replacements above or could apply only to the automated replacements. Again, maybe this regex should  come from a lua hook or perhaps the entire validity check should be done by a lua hook, either of which can be customized.

I've finally found some time to do something along these lines, committed to nvm in 280779a51cbfc28b7c59f8fe84dd084035febb5d. This adds two new lua hooks, unmapped_git_author(author) that attempts a few pattern matches and associated replacements to produce a valid git author from a monotone author and validate_git_author(author) that checks to ensure that git authors match a pattern as described above.

These new hooks allow for the possibility of requiring *every* author to be listed in the author map. By defining the unmapped_git_author hook to return an empty author (or some other invalid value) the validation hook will fail for any author not listed in the author map.

Existing author map files that map the "<unknown>" author will have to change to account for the unknown author now being called "Unknown <unknown>".

I have not tested this extensively on large databases other than monotone's on which it seems to work ok. It is somewhat careful to not slow down the export process by any appreciable amount.

Cheers,
Derek


reply via email to

[Prev in Thread] Current Thread [Next in Thread]