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

fix(config): gracefully fail when repo is in a detached HEAD state #765

Conversation

codejedi365
Copy link
Contributor

Purpose

Gracefully handle a TypeError when repository is in a detached HEAD state as occurs naturally in GitLab CI/CD environments.

Rationale

As I was setting up this library to run within GitLab CI/CD, I ran into an unhandled TypeError because of the detached HEAD state that GitLab's Runner Helper image sets up the environment by default. This is problematic due to the branch detection mechanism used in python-semantic-release. I opted to have the code gracefully catch this error and display a rationale to the user.

I have devised a way to manually resolve this problem in GitLab in the step before semantic-release is called but have not implemented an internal correction method (match the detached HEAD SHA to an equivalent branch and checkout). At the current time it will be up to the developer to ensure the state is correct.

How I tested

Outside of the manual integration tests I performed on GitLab, I added a test that purposefully mimics a detached HEAD state like GitLab does.

Copy link
Contributor

@bernardcooke53 bernardcooke53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bernardcooke53 bernardcooke53 merged commit ac4f9aa into python-semantic-release:master Dec 12, 2023
8 checks passed
@codejedi365 codejedi365 deleted the fix/git-detached-head-failure branch December 13, 2023 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants