Modify search autocompletion to include only email

When a user's full name is included in the query, the search excludes
commits where the full name does not appear in the author line. This may
be a subset of the actual changes pertaining to the user.

With this change, the search autocomplete results are instead generated
to only include the email when it is known.

Bug: Issue 7053
Change-Id: I4e20d6388f7b904c63786b9e87f9880a0f519b7e
This commit is contained in:
Kasper Nilsson
2017-11-21 11:43:52 -08:00
parent 3d97b49cdd
commit a226fd8698
2 changed files with 7 additions and 13 deletions

View File

@@ -189,14 +189,9 @@
MAX_AUTOCOMPLETE_RESULTS)
.then(accounts => {
if (!accounts) { return []; }
return accounts.map(acct => {
if (acct.email) {
return predicate + ':"' + this._accountOrAnon(acct) +
' <' + acct.email + '>"';
} else {
return predicate + ':"' + this._accountOrAnon(acct) + '"';
}
});
return accounts.map(acct => acct.email ?
`${predicate}:${acct.email}` :
`${predicate}:"${this._accountOrAnon(acct)}"`);
}).then(accounts => {
// When the expression supplied is a beginning substring of 'self',
// add it as an autocomplete option.

View File

@@ -105,7 +105,7 @@ limitations under the License.
});
suite('_getSearchSuggestions', () => {
test('Autocompletes accounts', done => {
test('Autocompletes accounts', () => {
sandbox.stub(element.$.restAPI, 'getSuggestedAccounts', () =>
Promise.resolve([
{
@@ -114,9 +114,8 @@ limitations under the License.
},
])
);
element._getSearchSuggestions('owner:fr').then(s => {
assert.equal(s[0].value, 'owner:"fred <fred@goog.co>"');
done();
return element._getSearchSuggestions('owner:fr').then(s => {
assert.equal(s[0].value, 'owner:fred@goog.co');
});
});
@@ -257,7 +256,7 @@ limitations under the License.
])
);
element._getSearchSuggestions('owner:fr').then(s => {
assert.equal(s[0].value, 'owner:"Anonymous <fred@goog.co>"');
assert.equal(s[0].value, 'owner:fred@goog.co');
done();
});
});