Skip to content
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

Detached Head Detection Improvement #588

Merged
merged 23 commits into from
Dec 18, 2024
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
99624f6
Merge pull request #256 from IBM/develop
drbruce-git Oct 17, 2022
83fbf19
Merge pull request #300 from IBM/zappbuild_301
dennis-behm Dec 16, 2022
5a649f0
Merge pull request #294 from IBM/develop
dennis-behm Mar 7, 2023
85e0df0
Merge pull request #354 from IBM/develop
dennis-behm May 15, 2023
9beaa58
Merge pull request #360 from IBM/develop
dennis-behm Jul 13, 2023
d018b5c
Merge pull request #392 from IBM/develop
dennis-behm Sep 1, 2023
d177891
Merge pull request #430 from IBM/develop
dennis-behm Oct 20, 2023
dd59b05
Merge pull request #456 from IBM/develop
dennis-behm Dec 15, 2023
f272ed7
Merge pull request #483 from IBM/develop
dennis-behm Mar 7, 2024
9f25617
Merge pull request #485 from IBM/develop
dennis-behm Mar 8, 2024
a719842
Merge pull request #503 from IBM/develop
dennis-behm Apr 10, 2024
f3dfad6
Merge pull request #524 from IBM/develop
dennis-behm Aug 15, 2024
7527814
Merge pull request #562 from IBM/develop
dennis-behm Nov 13, 2024
db9fb09
Merge pull request #575 from IBM/develop
dennis-behm Nov 26, 2024
4c9b0d7
Added new detached head code and testing code
kmcgreg5 Dec 17, 2024
38919d2
Fixed testing method call
kmcgreg5 Dec 17, 2024
5bb2fa5
Testing error message output
kmcgreg5 Dec 17, 2024
4f10ac6
Fixed error message condition
kmcgreg5 Dec 17, 2024
feb34f1
Removed testing code
kmcgreg5 Dec 18, 2024
f2060a1
Spacing
kmcgreg5 Dec 18, 2024
76aa923
Added -q option to suppress the error message on a detached head
kmcgreg5 Dec 18, 2024
6bad2e8
Added back testing code
kmcgreg5 Dec 18, 2024
a027e87
Removed testing code
kmcgreg5 Dec 18, 2024
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
7 changes: 5 additions & 2 deletions utilities/GitUtilities.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,20 @@ def getRemoteGitBranches(String gitDir) {
* @param String gitDir Local Git repository directory
*/
def isGitDetachedHEAD(String gitDir) {
String cmd = "git -C $gitDir status"
// If not detached, HEAD will be a symbolic-ref pointing to the branch
// If detached, HEAD will be a commit and this command will return a non-zero RC
String cmd = "git -C $gitDir symbolic-ref -q HEAD"
StringBuffer gitStatus = new StringBuffer()
StringBuffer gitError = new StringBuffer()

Process process = cmd.execute()
process.waitForProcessOutput(gitStatus, gitError)

if (gitError) {
println("*! Error executing Git command: $cmd error $gitError")
}

return gitStatus.toString().contains("HEAD detached at")
return process.exitValue() != 0;
}

/*
Expand Down