-
Notifications
You must be signed in to change notification settings - Fork 29
Fixed getting git metadata when started from a different dir to the project #385
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: main
Are you sure you want to change the base?
Conversation
…ferent directory and given a path to the repository.
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.
Nice to learn what was causing that!
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.
LGTM with one nitpicky comment
@@ -146,7 +146,7 @@ private void applyProjectPlugin(Project project, DevelocityAdapter develocity) { | |||
|
|||
BuildScanAdapter buildScan = develocity.getBuildScan(); | |||
customDevelocityConfig.configureBuildScanPublishing(buildScan); | |||
CustomBuildScanEnhancements buildScanEnhancements = new CustomBuildScanEnhancements(develocity, providers, project.getGradle()); | |||
CustomBuildScanEnhancements buildScanEnhancements = new CustomBuildScanEnhancements(develocity, providers, project.getGradle(), project.getRootDir().getAbsolutePath()); |
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.
Nitpick, but stylistically, I'd lean towards passing just the rootDir here as a a file, all the way into execAndGetStdOut
have that be the only place where we need to care about -C
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.
LGTM, just some minor format related comments
String gitCommitShortId = execAndGetStdOut("git", "rev-parse", "--short=8", "--verify", "HEAD"); | ||
String gitBranchName = getGitBranchName(() -> execAndGetStdOut("git", "rev-parse", "--abbrev-ref", "HEAD")); | ||
String gitStatus = execAndGetStdOut("git", "status", "--porcelain"); | ||
String gitRepo = execAndGetStdOut(projectDir, "git", "config", "--get", "remote.origin.url"); |
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.
It seems an extra space got inserted before the variable definition 🤷♂️ (same for the 4 next lines)
|
||
private CaptureGitMetadataAction(ProviderFactory providers, DevelocityAdapter develocity) { | ||
private CaptureGitMetadataAction(File projectDir, ProviderFactory providers, DevelocityAdapter develocity) { |
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.
I feel aligning the argument order with the constructor of CustomBuildScanEnhancements
would help to read the code. The ordering was unaligned before your change though.
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.
Great!
Fixed getting git data when the gradle build is started from a different directory and given a path to the repository. This can happen if the build is started with the
-p
/--project-dir
argument, or when using the GradleConnector as the main entrypoint - which is what is used by the VSCode gradle build server, added by gradle-java VSCode extension.To overcome this issue, I've added the
-C <root-project-path>
argument when running git commands, which will take care of such cases.I will investigate and open similar PRs for other CCUD implementations if we want to add this, and this is approved.