Skip to content
Browse files

Fix recognition of reviewers in commit message tags

A bug in JGit's footer match method caused "Sample-Bug-Id: 42"
to be treated identical to the footer line "Signed-off-by: 42".

Since Signed-off-by tags are converted into reviewers, we were adding
account number 42 as a reviewer anytime we saw "Sample-Bug-Id: 42".
This happened for any footer line key, so long as its length matched
the length of "Signed-off-by".

This was fixed in a newer version of JGit, so upgrade.

Also prevent "Signed-off-by: 42" from being treated as an account.
Within a commit message, we only want to match to a reviewer by
their full name or their email address.  Matching on their internal
database id number isn't useful.

Bug: issue 553
Change-Id: Ie26974240f26d29fb55cd95dc6b6c72c89903f37
Signed-off-by: Shawn O. Pearce <sop@google.com>
  • Loading branch information...
1 parent 3803582 commit c59e5eed68d8549d03fae417cc3876242216495e @spearce spearce committed May 4, 2010
View
8 ReleaseNotes/ReleaseNotes-2.1.2.4.txt
@@ -25,7 +25,13 @@ might not even be supported by the local JRE. In such cases the
ISO-8859-1 character set is used as a fallback, so the file content
is still visible.
-* Update JGit to 0.7.1.34-gf36df5d to fix empty tree bug
+* issue 553 Bugs sometimes added as change reviewers
++
+Bug references were sometimes added as an 'Anonymous Coward' change
+reviewer when the line used to mention the bug in the commit message
+was the same length as 'Signed-off-by'. Fixed.
+
+* Update JGit to 0.7.1.46-gdd63f5c to fix empty tree bug
+
Repositories which contained an empty tree object (very uncommon, its
technically a bug to produce a repository like this) wouldn't clone
View
19 gerrit-server/src/main/java/com/google/gerrit/server/account/AccountResolver.java
@@ -45,8 +45,9 @@
* Locate exactly one account matching the name or name/email string.
*
* @param nameOrEmail a string of the format
- * "Full Name &lt;email@example&gt;", or just the email address
- * ("email@example"), or a full name, or an account id.
+ * "Full Name &lt;email@example&gt;", just the email address
+ * ("email@example"), a full name ("Full Name"), or an account id
+ * ("18419").
* @return the single account that matches; null if no account matches or
* there are multiple candidates.
*/
@@ -60,6 +61,20 @@ public Account find(final String nameOrEmail) throws OrmException {
return byId.get(Account.Id.parse(nameOrEmail)).getAccount();
}
+ return findByNameOrEmail(nameOrEmail);
+ }
+
+ /**
+ * Locate exactly one account matching the name or name/email string.
+ *
+ * @param nameOrEmail a string of the format
+ * "Full Name &lt;email@example&gt;", just the email address
+ * ("email@example"), a full name ("Full Name").
+ * @return the single account that matches; null if no account matches or
+ * there are multiple candidates.
+ */
+ public Account findByNameOrEmail(final String nameOrEmail)
+ throws OrmException {
final int lt = nameOrEmail.indexOf('<');
final int gt = nameOrEmail.indexOf('>');
if (lt >= 0 && gt > lt && nameOrEmail.contains("@")) {
View
2 gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java
@@ -388,7 +388,7 @@ private static boolean missing(final String value) {
private Account.Id toAccountId(final String nameOrEmail) throws OrmException,
NoSuchAccountException {
- final Account a = accountResolver.find(nameOrEmail);
+ final Account a = accountResolver.findByNameOrEmail(nameOrEmail);
if (a == null) {
throw new NoSuchAccountException("\"" + nameOrEmail
+ "\" is not registered");
View
2 pom.xml
@@ -46,7 +46,7 @@ limitations under the License.
</issueManagement>
<properties>
- <jgitVersion>0.7.1.34-gf36df5d</jgitVersion>
+ <jgitVersion>0.7.1.46-gdd63f5c</jgitVersion>
<gwtormVersion>1.1.4</gwtormVersion>
<gwtjsonrpcVersion>1.2.2</gwtjsonrpcVersion>
<gwtexpuiVersion>1.2.1</gwtexpuiVersion>

0 comments on commit c59e5ee

Please sign in to comment.
Something went wrong with that request. Please try again.