Skip to content
Open
Show file tree
Hide file tree
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
Expand Up @@ -32,4 +32,6 @@ public interface VersionDetails {
boolean getIsCleanTag();

String getVersion();

String getOriginUrl();
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class VersionDetailsImpl implements VersionDetails {
private Provider<Boolean> isClean;
private Provider<String> gitHashFull;
private Provider<String> branchName;
private Provider<String> originUrl;

VersionDetailsImpl(ProviderFactory providerFactory, File gitDir, GitVersionArgs gitVersionArgs) {
String projectDir = gitDir.getParent();
Expand All @@ -53,6 +54,7 @@ class VersionDetailsImpl implements VersionDetails {
this.isClean = git.run("status", "--porcelain").map(String::isEmpty);
this.gitHashFull = git.run("rev-parse", "HEAD");
this.branchName = git.run("branch", "--show-current");
this.originUrl = git.run("config", "remote.origin.url");
}

@Override
Expand Down Expand Up @@ -136,6 +138,16 @@ public String getBranchName() {
}
}

@Override
public String getOriginUrl() {
try {
return Strings.emptyToNull(this.originUrl.get());
} catch (RuntimeException e) {
log.error("VersionDetailsImpl::getOriginUrl failed", e);
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message 'VersionDetailsImpl::getOriginUrl failed' doesn't provide helpful context about why the operation failed. Consider including more specific information, such as 'Failed to retrieve git remote origin URL' to make debugging easier for users.

Suggested change
log.error("VersionDetailsImpl::getOriginUrl failed", e);
log.error("Failed to retrieve git remote origin URL in VersionDetailsImpl#getOriginUrl", e);

Copilot uses AI. Check for mistakes.
return null;
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method returns null when the origin URL is empty or when an exception occurs, making it impossible for callers to distinguish between these two scenarios. Consider throwing a meaningful exception or returning an Optional to better communicate the absence of a value versus an error condition.

Suggested change
return null;
throw e;

Copilot uses AI. Check for mistakes.
}
}

@Override
public String toString() {
try {
Expand Down