Skip to content

regex in getCurrentBranch works not for 'detached HEAD' checkouts #75

@pantovad

Description

@pantovad

Hello,

Again the getCurrentBranch logic (regex) does not work for 'detached HEAD' checkouts (typical in Jenkins):

# git checkout -f 5e67f0ea05c202963b91ccdea78f6623c7fbdecf
Note: switching to '5e67f0ea05c202963b91ccdea78f6623c7fbdecf'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 5e67f0ea0 PROJECT-3518 upgrade semver plugin to 2.3.7

# git log -n1 --pretty=%d HEAD
 (HEAD, origin/PROJECT-3518-upgrade-semver, PROJECT-3518-upgrade-semver)

or from Jenkins job:


13:31:22  + git version
13:31:22  git version 2.20.1
13:31:22  + git log -n1 --pretty=%d HEAD
13:31:22   (HEAD, origin/PROJECT-3518-upgrade-semver)

And the output from showInfo is:

13:31:37  > Task :showInfo
13:31:37  Branch name: 
13:31:37  Branch group: 
13:31:37  Branch id: 
13:31:37  Commit: 5e67f0ea05c202963b91ccdea78f6623c7fbdecf
13:31:37  Short commit: 5e67f0ea0
13:31:37  Tag: none
13:31:37  Last tag: my-project-5.7.6-86-g5e67f0e
13:31:37  Dirty: true
13:31:37  Version: 5.8.0+build.16527.sha.5e67f0ea0-dirty-SNAPSHOT
13:31:37  Version major: 5
13:31:37  Version minor: 8
13:31:37  Version patch: 0
13:31:37  Version pre release: none
13:31:37  Version build: none

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions