use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testSendHtmlMail.
@Test
public void testSendHtmlMail() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
commands.add(new ReceiveCommand(ObjectId.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));
RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");
repository.mailingLists.add("list@helloworld.git");
test("sendmail-html.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(1, logger.messages.size());
assertEquals(1, gitblit.messages.size());
MockMail m = gitblit.messages.get(0);
assertEquals(5, m.toAddresses.size());
assertTrue(m.message.contains("BIT"));
assertTrue(m.message.contains("<html>"));
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testFogbugz.
@Test
public void testFogbugz() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
commands.add(new ReceiveCommand(ObjectId.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master2"));
RepositoryModel repository = repositories().getRepositoryModel("helloworld.git");
repository.customFields = new HashMap<String, String>();
repository.customFields.put("fogbugzUrl", "http://bugs.test.com");
repository.customFields.put("fogbugzRepositoryId", "1");
repository.customFields.put("fogbugzCommitMessageRegex", "\\s*[Bb][Uu][Gg][(Zz)(Ss)]*\\s*[(IDs)]*\\s*[#:; ]+((\\d+[ ,:;#]*)+)");
test("fogbugz.groovy", gitblit, logger, clientLogger, commands, repository);
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testProtectRefsDeleteMasterBranch.
@Test
public void testProtectRefsDeleteMasterBranch() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
ReceiveCommand command = new ReceiveCommand(ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(), "refs/heads/master");
commands.add(command);
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(ReceiveCommand.Result.REJECTED_NODELETE, command.getResult());
assertEquals(0, logger.messages.size());
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testProtectRefsCreateTag.
@Test
public void testProtectRefsCreateTag() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/tags/v1.0"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(0, logger.messages.size());
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gerrit by GerritCodeReview.
the class CommentsUtil method deleteAllDraftsFromAllUsers.
public void deleteAllDraftsFromAllUsers(Change.Id changeId) throws IOException {
try (Repository repo = repoManager.openRepository(allUsers);
RevWalk rw = new RevWalk(repo)) {
BatchRefUpdate bru = repo.getRefDatabase().newBatchUpdate();
for (Ref ref : getDraftRefs(repo, changeId)) {
bru.addCommand(new ReceiveCommand(ref.getObjectId(), ObjectId.zeroId(), ref.getName()));
}
bru.setRefLogMessage("Delete drafts from NoteDb", false);
bru.execute(rw, NullProgressMonitor.INSTANCE);
for (ReceiveCommand cmd : bru.getCommands()) {
if (cmd.getResult() != ReceiveCommand.Result.OK) {
throw new IOException(String.format("Failed to delete draft comment ref %s at %s: %s (%s)", cmd.getRefName(), cmd.getOldId(), cmd.getResult(), cmd.getMessage()));
}
}
}
}
Aggregations