Skip to content

Default missing/empty rev to main before checkout - #535

Merged
jacebrowning merged 2 commits into
jacebrowning:mainfrom
Muhtasim-Munif-Fahim:fix/533-default-rev-when-missing
Nov 9, 2026
Merged

jacebrowning merged 2 commits into
jacebrowning:mainfrom
Muhtasim-Munif-Fahim:fix/533-default-rev-when-missing

Conversation

@Muhtasim-Munif-Fahim

Copy link
Copy Markdown
Contributor

Summary

When rev is omitted from a source in .gitman.yml, datafiles loads the nested dataclass field as an empty string. That bypasses the declared default of "main" and leads to git checkout --force "", which fails with:

fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths

Source.__post_init__ now treats a missing/empty rev as "main", matching the documented default.

Fixes #533

Test plan

  • Added unit tests for empty-string and None rev values
  • Verified YAML load of a source with no rev key yields rev == "main"
  • pytest gitman/tests/test_models_source.py passes

AI assistance was used while preparing this change.

When `rev` is omitted from `.gitman.yml`, datafiles loads it as an empty
string, which bypasses the dataclass default of `"main"` and causes
`git checkout --force ""` to fail. Normalize empty/missing rev to
`"main"` in `Source.__post_init__`, matching the documented default.

Fixes jacebrowning#533
@filipopo

filipopo commented Nov 9, 2026 •

Copy link
Copy Markdown

Hey @Muhtasim-Munif-Fahim can you fix the tests from the failed check?

gitman\tests\test_models_source.py:50: error: Argument "rev" to "Source" has incompatible type "None"; expected "str"

@jacebrowning
jacebrowning self-requested a review November 9, 2026 20:26
@jacebrowning
jacebrowning merged commit b150322 into jacebrowning:main Nov 9, 2026
7 checks passed
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.

gitman install fails without ref, even when the default branch is "main"

3 participants