gperdomor / nx-tools

Nx Workspaces builders and tools
MIT License
358 stars 56 forks source link

Git context fails if branch name contains a slash #1120

Open arvidboivie opened 2 months ago

arvidboivie commented 2 months ago

Trying to set up builds with @nx-tools/nx-container on a CodeBuild with a Bitbucket Server source, I'm getting this error:

Unsupported CI Provider... Using Git as fallback
[..]
NX   Unsupported detached HEAD ref in "HEAD, origin/feature/branch-name, feature/branch-name"

As far as I can tell, this is because when using the git context (specifically on this line: https://github.com/gperdomor/nx-tools/blob/df601249cd340686169cf7488e1f7adf030692f9/packages/ci-context/src/lib/utils/git.ts#L84) the regex fails to pick up branch names with a slash in them. I think this should be supported, since prefixes like feature/ or bugfix/ are fairly common.

Replacing the second [^/]+ with something more permissive should fix this, but perhaps there's other complexities I'm not aware of.