Why I see HEAD as branch name in user dashboard for Build metrics for my API token?
knapsack_pro detects your branch name from environment variables of supported CI providers. Sometimes the CI provider may expose the
HEAD instead of branch name (for instance for pull request merge commits).
The same can happen for CI provider not supported by default by
knapsack_pro when you use
KNAPSACK_PRO_REPOSITORY_ADAPTER=git (see) to use local git installed on CI node to detect the branch name and git commit.
knapsack_pro uses git command
git -C /home/user/project_dir rev-parse --abbrev-ref HEAD to detect branch name. See source of knapsack_pro. In most of cases it's good way to detect branch name. But if your CI provider during CI build checkouts to specific git commit then git cannot provide the name of the branch. In such scenario you would see
HEAD as your branch name. It is good enough situation and
knapsack_pro will work correctly. The benefit of knowing exactly the branch name allows KnapsackPro API to better track history of test files timing changes across branches in order to better do split of test suite. The difference should be rather very small so it's not a problem that you have
HEAD as branch name.
If you would like to see exact branch name instead of
HEAD in your
build metrics history in user dashboard then you can explicitly provide the branch name with
KNAPSACK_PRO_BRANCH for each CI build.