Skip to content

Commit

Permalink
Use last revision from mercurial repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
FrantaM committed Dec 1, 2014
1 parent 54ca329 commit 28c38cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/me/cmoz/gradle/snapshot/HgSCMCommand.java
Expand Up @@ -19,6 +19,7 @@
import lombok.SneakyThrows;
import org.gradle.api.Project;
import org.tmatesoft.hg.core.*;
import org.tmatesoft.hg.repo.HgRepository;

import javax.annotation.Nullable;
import java.io.File;
Expand Down Expand Up @@ -57,8 +58,13 @@ public Commit getLatestCommit(@NonNull final String dateFormat) {

final SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);

final int lastRevision = repo.getRepository().getChangelog().getLastRevision();
if (lastRevision == HgRepository.NO_REVISION) {
throw new RuntimeException("Could not find any changesets in Hg repository.");
}

final HgLogCommand hgLogCommand = repo.createLogCommand();
hgLogCommand.limit(1);
hgLogCommand.range(lastRevision, lastRevision);
final List<HgChangeset> changesets = hgLogCommand.execute();
if (changesets.size() < 1) {
throw new RuntimeException("Could not find any changesets in Hg repository.");
Expand Down

0 comments on commit 28c38cc

Please sign in to comment.