Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2152: Use full name for tags if possible #1603

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -116,7 +116,8 @@ public void handle(PullRequestBot bot, HostedCommit commit, LimitedCensusInstanc
var contributor = censusInstance.contributor(command.user()).orElseThrow();
var email = contributor.username() + "@" + domain;
var message = "Added tag " + tagName + " for changeset " + commit.hash().abbreviate();
var tag = localRepo.tag(commit.hash(), tagName, message, contributor.username(), email);
var name = contributor.fullName().isPresent() ? contributor.fullName().get() : contributor.username();
var tag = localRepo.tag(commit.hash(), tagName, message, name, email);
localRepo.push(tag, bot.repo().authenticatedUrl(), false);
reply.println("The tag [" + tag.name() + "](" + bot.repo().webUrl(tag) + ") was successfully created.");
} catch (IOException e) {
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.openjdk.skara.test.*;
import org.openjdk.skara.vcs.Author;
import org.openjdk.skara.vcs.Tag;
import org.openjdk.skara.vcs.Repository;

@@ -304,4 +305,53 @@ void nonConformingTag(TestInfo testInfo) throws IOException {
assertEquals(List.of(), tags);
}
}

@Test
void metadata(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory()) {
var author = credentials.getHostedRepository();
var reviewer = credentials.getHostedRepository();

var censusBuilder = credentials.getCensusBuilder()
.addAuthor(author.forge().currentUser().id())
.addReviewer(reviewer.forge().currentUser().id());
var seedFolder = tempFolder.path().resolve("seed");
var bot = PullRequestBot.newBuilder()
.repo(author)
.integrators(Set.of(author.forge().currentUser().username()))
.censusRepo(censusBuilder.build())
.censusLink("https://census.com/{{contributor}}-profile")
.seedStorage(seedFolder)
.forks(Map.of(author.name(), author))
.build();

// Populate the projects repository
var localRepo = CheckableRepository.init(tempFolder.path(), author.repositoryType());
var masterHash = CheckableRepository.appendAndCommit(localRepo);
localRepo.push(masterHash, author.authenticatedUrl(), "master", true);

// Add a tag command
author.addCommitComment(masterHash, "/skara tag v1.0");
TestBotRunner.runPeriodicItems(bot);

var recentCommitComments = author.recentCommitComments();
assertEquals(2, recentCommitComments.size());
var botReply = recentCommitComments.get(0);
assertTrue(botReply.body().contains("tag"));
assertTrue(botReply.body().contains("was successfully created"));

var localAuthorRepoDir = tempFolder.path().resolve("author");
var localAuthorRepo = Repository.clone(author.authenticatedUrl(), localAuthorRepoDir);
var tags = localAuthorRepo.tags();
assertEquals(List.of(new Tag("v1.0")), tags);

var tag = localAuthorRepo.annotate(tags.get(0));
assertTrue(tag.isPresent());
assertEquals(masterHash, tag.get().target());
assertEquals("v1.0", tag.get().name());
assertEquals("Added tag v1.0 for changeset " + masterHash.abbreviate(), tag.get().message());
assertEquals(Author.fromString("Generated Author 1 <integrationauthor1@openjdk.org>"), tag.get().author());
}
}
}