-
Notifications
You must be signed in to change notification settings - Fork 74
Add originUrl to versionDetails #1155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,4 +32,6 @@ public interface VersionDetails { | |
| boolean getIsCleanTag(); | ||
|
|
||
| String getVersion(); | ||
|
|
||
| String getOriginUrl(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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(); | ||||||
|
|
@@ -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 | ||||||
|
|
@@ -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); | ||||||
| return null; | ||||||
|
||||||
| return null; | |
| throw e; |
There was a problem hiding this comment.
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.