Search in sources :

Example 61 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.

the class ChangeNotesParser method parseRealAccountId.

private Account.Id parseRealAccountId(ChangeNotesCommit commit, Account.Id effectiveAccountId) throws ConfigInvalidException {
    String realUser = parseOneFooter(commit, FOOTER_REAL_USER);
    if (realUser == null) {
        return effectiveAccountId;
    }
    PersonIdent ident = RawParseUtils.parsePersonIdent(realUser);
    return noteUtil.parseIdent(ident, id);
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent)

Example 62 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.

the class ChangeUpdate method addIdent.

private StringBuilder addIdent(StringBuilder sb, Account.Id accountId) {
    Account account = accountCache.get(accountId).getAccount();
    PersonIdent ident = newIdent(account, when);
    PersonIdent.appendSanitized(sb, ident.getName());
    sb.append(" <");
    PersonIdent.appendSanitized(sb, ident.getEmailAddress());
    sb.append('>');
    return sb;
}
Also used : Account(com.google.gerrit.reviewdb.client.Account) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GerritPersonIdent(com.google.gerrit.server.GerritPersonIdent)

Example 63 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.

the class ChangeNotesParser method parseAssignee.

private void parseAssignee(ChangeNotesCommit commit) throws ConfigInvalidException {
    if (pastAssignees == null) {
        pastAssignees = Lists.newArrayList();
    }
    String assigneeValue = parseOneFooter(commit, FOOTER_ASSIGNEE);
    if (assigneeValue != null) {
        Optional<Account.Id> parsedAssignee;
        if (assigneeValue.equals("")) {
            // Empty footer found, assignee deleted
            parsedAssignee = Optional.empty();
        } else {
            PersonIdent ident = RawParseUtils.parsePersonIdent(assigneeValue);
            parsedAssignee = Optional.ofNullable(noteUtil.parseIdent(ident, id));
        }
        if (assignee == null) {
            assignee = parsedAssignee;
        }
        if (parsedAssignee.isPresent()) {
            pastAssignees.add(parsedAssignee.get());
        }
    }
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent) LabelId(com.google.gerrit.reviewdb.client.LabelId) ObjectId(org.eclipse.jgit.lib.ObjectId) RevId(com.google.gerrit.reviewdb.client.RevId)

Example 64 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.

the class FromAddressGeneratorProviderTest method setUp.

@Before
public void setUp() throws Exception {
    config = new Config();
    ident = new PersonIdent("NAME", "e@email", 0, 0);
    accountCache = createStrictMock(AccountCache.class);
}
Also used : AccountCache(com.google.gerrit.server.account.AccountCache) PersonIdent(org.eclipse.jgit.lib.PersonIdent) Config(org.eclipse.jgit.lib.Config) Before(org.junit.Before)

Example 65 with PersonIdent

use of org.eclipse.jgit.lib.PersonIdent in project gerrit by GerritCodeReview.

the class AbstractChangeNotesTest method setUp.

@Before
public void setUp() throws Exception {
    setTimeForTesting();
    serverIdent = new PersonIdent("Gerrit Server", "noreply@gerrit.com", TimeUtil.nowTs(), TZ);
    project = new Project.NameKey("test-project");
    repoManager = new InMemoryRepositoryManager();
    repo = repoManager.createRepository(project);
    tr = new TestRepository<>(repo);
    rw = tr.getRevWalk();
    accountCache = new FakeAccountCache();
    Account co = new Account(new Account.Id(1), TimeUtil.nowTs());
    co.setFullName("Change Owner");
    co.setPreferredEmail("change@owner.com");
    accountCache.put(co);
    Account ou = new Account(new Account.Id(2), TimeUtil.nowTs());
    ou.setFullName("Other Account");
    ou.setPreferredEmail("other@account.com");
    accountCache.put(ou);
    injector = Guice.createInjector(new FactoryModule() {

        @Override
        public void configure() {
            install(new GitModule());
            install(NoteDbModule.forTest(testConfig));
            bind(AllUsersName.class).toProvider(AllUsersNameProvider.class);
            bind(String.class).annotatedWith(GerritServerId.class).toInstance("gerrit");
            bind(NotesMigration.class).toInstance(MIGRATION);
            bind(GitRepositoryManager.class).toInstance(repoManager);
            bind(ProjectCache.class).toProvider(Providers.<ProjectCache>of(null));
            bind(CapabilityControl.Factory.class).toProvider(Providers.<CapabilityControl.Factory>of(null));
            bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(testConfig);
            bind(String.class).annotatedWith(AnonymousCowardName.class).toProvider(AnonymousCowardNameProvider.class);
            bind(String.class).annotatedWith(CanonicalWebUrl.class).toInstance("http://localhost:8080/");
            bind(Boolean.class).annotatedWith(DisableReverseDnsLookup.class).toInstance(Boolean.FALSE);
            bind(Realm.class).to(FakeRealm.class);
            bind(GroupBackend.class).to(SystemGroupBackend.class).in(SINGLETON);
            bind(AccountCache.class).toInstance(accountCache);
            bind(PersonIdent.class).annotatedWith(GerritPersonIdent.class).toInstance(serverIdent);
            bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
            bind(MetricMaker.class).to(DisabledMetricMaker.class);
            bind(ReviewDb.class).toProvider(Providers.<ReviewDb>of(null));
        }
    });
    injector.injectMembers(this);
    repoManager.createRepository(allUsers);
    changeOwner = userFactory.create(co.getId());
    otherUser = userFactory.create(ou.getId());
    otherUserId = otherUser.getAccountId();
    internalUser = new InternalUser(null);
}
Also used : MetricMaker(com.google.gerrit.metrics.MetricMaker) DisabledMetricMaker(com.google.gerrit.metrics.DisabledMetricMaker) Account(com.google.gerrit.reviewdb.client.Account) InMemoryRepositoryManager(com.google.gerrit.testutil.InMemoryRepositoryManager) CapabilityControl(com.google.gerrit.server.account.CapabilityControl) InternalUser(com.google.gerrit.server.InternalUser) GerritServerId(com.google.gerrit.server.config.GerritServerId) DisableReverseDnsLookup(com.google.gerrit.server.config.DisableReverseDnsLookup) GitReferenceUpdated(com.google.gerrit.server.extensions.events.GitReferenceUpdated) FakeAccountCache(com.google.gerrit.testutil.FakeAccountCache) SystemGroupBackend(com.google.gerrit.server.group.SystemGroupBackend) FakeRealm(com.google.gerrit.server.account.FakeRealm) Realm(com.google.gerrit.server.account.Realm) ReviewDb(com.google.gerrit.reviewdb.server.ReviewDb) GerritPersonIdent(com.google.gerrit.server.GerritPersonIdent) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) AnonymousCowardName(com.google.gerrit.server.config.AnonymousCowardName) CanonicalWebUrl(com.google.gerrit.server.config.CanonicalWebUrl) FactoryModule(com.google.gerrit.extensions.config.FactoryModule) GitModule(com.google.gerrit.server.git.GitModule) GitRepositoryManager(com.google.gerrit.server.git.GitRepositoryManager) TestNotesMigration(com.google.gerrit.testutil.TestNotesMigration) FakeAccountCache(com.google.gerrit.testutil.FakeAccountCache) AccountCache(com.google.gerrit.server.account.AccountCache) Project(com.google.gerrit.reviewdb.client.Project) ProjectCache(com.google.gerrit.server.project.ProjectCache) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GerritPersonIdent(com.google.gerrit.server.GerritPersonIdent) AllUsersName(com.google.gerrit.server.config.AllUsersName) Before(org.junit.Before)

Aggregations

PersonIdent (org.eclipse.jgit.lib.PersonIdent)86 RevCommit (org.eclipse.jgit.revwalk.RevCommit)23 Test (org.junit.Test)21 CommitBuilder (org.eclipse.jgit.lib.CommitBuilder)19 ObjectId (org.eclipse.jgit.lib.ObjectId)18 GerritPersonIdent (com.google.gerrit.server.GerritPersonIdent)15 RevWalk (org.eclipse.jgit.revwalk.RevWalk)13 Change (com.google.gerrit.reviewdb.client.Change)12 ObjectInserter (org.eclipse.jgit.lib.ObjectInserter)12 Repository (org.eclipse.jgit.lib.Repository)11 Account (com.google.gerrit.reviewdb.client.Account)10 IOException (java.io.IOException)9 RefUpdate (org.eclipse.jgit.lib.RefUpdate)9 Ref (org.eclipse.jgit.lib.Ref)8 TestRepository (org.eclipse.jgit.junit.TestRepository)7 Date (java.util.Date)6 Result (org.eclipse.jgit.lib.RefUpdate.Result)6 ArrayList (java.util.ArrayList)5 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)4