diff --git a/src/main/groovy/nebula/plugin/release/git/command/GitReadCommand.groovy b/src/main/groovy/nebula/plugin/release/git/command/GitReadCommand.groovy index 3fbcf87..7289fb4 100644 --- a/src/main/groovy/nebula/plugin/release/git/command/GitReadCommand.groovy +++ b/src/main/groovy/nebula/plugin/release/git/command/GitReadCommand.groovy @@ -157,11 +157,11 @@ abstract class CommitFromTag extends GitReadCommand { /** * Uses to determine if a given repo has any commit */ -abstract class DescribeTags extends GitReadCommand { +abstract class AnyCommit extends GitReadCommand { @Override String obtain() { try { - return executeGitCommand( "describe", "--tags", "--always") + return executeGitCommand( "rev-list", "-n", "1", "--all") .replaceAll("\n", "").trim() } catch (Exception e) { return null diff --git a/src/main/groovy/nebula/plugin/release/git/command/GitReadOnlyCommandUtil.groovy b/src/main/groovy/nebula/plugin/release/git/command/GitReadOnlyCommandUtil.groovy index 96db91d..d82d903 100644 --- a/src/main/groovy/nebula/plugin/release/git/command/GitReadOnlyCommandUtil.groovy +++ b/src/main/groovy/nebula/plugin/release/git/command/GitReadOnlyCommandUtil.groovy @@ -14,7 +14,7 @@ class GitReadOnlyCommandUtil implements Serializable { private Provider emailFromLogProvider private Provider currentBranchProvider private Provider isGitRepoProvider - private Provider describeTagsProvider + private Provider anyCommitProvider private Provider revParseHeadProvider private Provider headTagsProvider private Provider refTagsProvider @@ -48,7 +48,7 @@ class GitReadOnlyCommandUtil implements Serializable { isGitRepoProvider = providers.of(IsGitRepo.class) { it.parameters.rootDir.set(rootDir) } - describeTagsProvider = providers.of(DescribeTags.class) { + anyCommitProvider = providers.of(AnyCommit.class) { it.parameters.rootDir.set(rootDir) } revParseHeadProvider = providers.of(RevParseHead.class) { @@ -108,8 +108,8 @@ class GitReadOnlyCommandUtil implements Serializable { Boolean hasCommit() { try { - String describe = describeTagsProvider.get().toString() - return describe != null && !describe.contains("fatal:") + String describe = anyCommitProvider.get().toString() + return describe != null && !describe.empty && !describe.contains("fatal:") } catch (Exception e) { return false }