Skip to content

Conversation

@palantir-sachin
Copy link

@palantir-sachin palantir-sachin commented Jan 12, 2026

Changes

Adds getOriginUrl() method to VersionDetails interface to expose the git remote origin URL

==COMMIT_MSG==
Add originUrl to versionDetails to get the value of git config remote.origin.url
==COMMIT_MSG==

@changelog-app
Copy link

changelog-app bot commented Jan 12, 2026

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Add originUrl to versionDetails to get the value of git config remote.origin.url

Check the box to generate changelog(s)

  • Generate changelog entry

@palantir-sachin palantir-sachin force-pushed the sahuja/origin-url branch 5 times, most recently from 058af76 to ab6ad4e Compare January 13, 2026 02:50
@palantir-sachin palantir-sachin changed the title [DRAFT] Adding origin url Add originUrl to versionDetails Jan 13, 2026
@changelog-app
Copy link

changelog-app bot commented Jan 13, 2026

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

💡 Improvements

  • Add originUrl to versionDetails to get the value of git config remote.origin.url (#1155)

@palantir-sachin palantir-sachin marked this pull request as ready for review January 13, 2026 03:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds functionality to expose the git remote origin URL through the VersionDetails interface by implementing a new getOriginUrl() method that executes git config remote.origin.url.

Changes:

  • Added getOriginUrl() method to VersionDetails interface
  • Implemented getOriginUrl() in VersionDetailsImpl with error handling
  • Initialized originUrl provider using git config command

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/java/com/palantir/gradle/gitversion/VersionDetails.java Added getOriginUrl() method signature to the interface
src/main/java/com/palantir/gradle/gitversion/VersionDetailsImpl.java Implemented getOriginUrl() method with provider initialization and error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return Strings.emptyToNull(this.originUrl.get());
} catch (RuntimeException e) {
log.error("VersionDetailsImpl::getOriginUrl failed", e);
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.
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.
@felixdesouza
Copy link

can you add to the existing tests please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants