Skip to content

Jujutsu unfriendly submit #72

@bolivier

Description

@bolivier

If you're using Jujutsu, you cannot submit despite the HEAD being on the correct commit (ie. the tip of the master branch). Jujutsu leaves you in a detached HEAD state by default. You can switch the branch manually, and then submit works as expected.

A slight change to the branch detection command (adds no dependencies, and still only relies on git) will allow Jujutsu users to seamlessly use the codecrafters CLI.

I'm happy to make the change myself, but I wanted to make sure it would be accepted.

The issue stems from this code:

func getCurrentBranch(repoDir string) (string, error) {
outputBytes, err := exec.Command("git", "-C", repoDir, "rev-parse", "--abbrev-ref", "HEAD").CombinedOutput()
if err != nil {
return "", wrapError(err, outputBytes, "get current branch")
}
return strings.TrimSpace(string(outputBytes)), nil
}

This currently runs something like

git -C . rev-parse --abbrev-ref HEAD

and the following would make Jujutsu work as expected

git for-each-ref --format=%(refname:short) --points-at HEAD refs/heads

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions