Skip to content

Commit

Permalink
Status.UP_TO_DATE is successful
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattias Andersson committed Apr 8, 2024
1 parent 2f6591c commit dca79a8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ protected CheckOutScmResult checkOut(File workingDirectory, ScmRepository reposi
}
}

@Test
public void testUpToDatePush() throws Exception {
File checkedOutRepo = getWorkingCopy();

ScmRepository scmRepository = getScmManager().makeScmRepository(getScmUrl());
checkoutRepoInto(checkedOutRepo, scmRepository);

// Add a default user to the config
GitScmTestUtils.setDefaulGitConfig(checkedOutRepo);

CheckInScmResult result =
getScmManager().checkIn(scmRepository, new ScmFileSet(checkedOutRepo), "No change commit message");

assertResultIsSuccess(result);
}

@Test
public void testRejectedNonFastForwardPush() throws Exception {
File blockingRepo = PlexusJUnit4TestSupport.getTestFile("target/scm-test/blocking-repo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected CheckInScmResult executeCheckInCommand(

for (PushResult pushResult : pushResultList) {
for (RemoteRefUpdate remoteRefUpdate : pushResult.getRemoteUpdates()) {
if (remoteRefUpdate.getStatus() != RemoteRefUpdate.Status.OK) {
if (!isSuccessStatus(remoteRefUpdate.getStatus())) {
return new CheckInScmResult(
"JGit checkin",
"The git-push command failed, with status: " + remoteRefUpdate.getStatus(),
Expand All @@ -164,7 +164,13 @@ protected CheckInScmResult executeCheckInCommand(
}
}

private boolean isSuccessStatus(RemoteRefUpdate.Status remoteRefUpdateStatus) {
return remoteRefUpdateStatus == RemoteRefUpdate.Status.OK
|| remoteRefUpdateStatus == RemoteRefUpdate.Status.UP_TO_DATE;
}

private static final class UserInfo {

final String name;

final String email;
Expand Down

0 comments on commit dca79a8

Please sign in to comment.