tests.test_git_ops moduleΒΆ
Tests for Git operations module.
- tests.test_git_ops.git_workdir(tmp_path, monkeypatch, hermetic_git)[source]ΒΆ
A working clone (cwd) of a bare
originremote, one commit on main.
- tests.test_git_ops.shallow_clone(tmp_path, monkeypatch, hermetic_git)[source]ΒΆ
The SHAs of a depth-1 cloneβs remote history, the clone being the cwd.
- tests.test_git_ops.test_git_error_carries_stderr(git_workdir)[source]ΒΆ
A failure names the command and carries gitβs own error output.
- tests.test_git_ops.test_show_file_reads_a_past_commit_in_place(git_workdir)[source]ΒΆ
A past version of a file is read without moving
HEAD.
- tests.test_git_ops.test_create_and_push_tag_publishes_the_tag(git_workdir, tmp_path)[source]ΒΆ
The tag lands on the remote, at
HEADby default.
- tests.test_git_ops.test_create_and_push_tag_at_commit_without_push(git_workdir, tmp_path)[source]ΒΆ
A tag can point at an older commit, and stay local.
- tests.test_git_ops.test_create_and_push_tag_skips_an_existing_tag(git_workdir)[source]ΒΆ
Re-running the tag step is a no-op, unless asked to fail.
- tests.test_git_ops.test_create_and_push_tag_matches_the_exact_tag(git_workdir)[source]ΒΆ
A tag whose name only ends like the one asked for is not a match.
- tests.test_git_ops.test_git_tag_command_reports_each_outcome(git_workdir, tmp_path)[source]ΒΆ
The command reports a new tag, skips an existing one, or fails on it.
- tests.test_git_ops.test_version_tags_skip_names_that_do_not_parse(git_workdir)[source]ΒΆ
A tag the glob selects but PEP 440 refuses is left out of every reader.
- tests.test_git_ops.test_fetch_commit_brings_a_commit_without_its_history(shallow_clone)[source]ΒΆ
A commit fetched on its own is a boundary of its own.
- tests.test_git_ops.test_fetch_commit_reports_a_commit_the_remote_does_not_serve(shallow_clone)[source]ΒΆ
- tests.test_git_ops.test_deepening_relates_a_commit_fetched_on_its_own(shallow_clone)[source]ΒΆ
Presence of both ends is not enough to walk the range between them.
The order
metadataresolves its keys in can fetch the start of the range before the range itself is resolved. A range walked from there would stop at the boundary of the clone, and miss every commit below the tip.
- tests.test_git_ops.test_deepening_stops_on_a_complete_clone(git_workdir)[source]ΒΆ
A complete clone has no boundary to deepen: unrelated commits stay so.
- tests.test_git_ops.test_get_latest_tag_version()[source]ΒΆ
Test that we can retrieve the latest Git tag version.
- tests.test_git_ops.test_get_release_version_from_commits()[source]ΒΆ
Test that get_release_version_from_commits returns expected type.
This function searches recent commits for release messages matching
[changelog] Release vX.Y.Zpattern and extracts the version.
- tests.test_git_ops.test_get_release_version_from_commits_max_count()[source]ΒΆ
Test that max_count parameter limits commit search.
- tests.test_git_ops.test_is_version_bump_allowed_returns_bool()[source]ΒΆ
Test that is_version_bump_allowed returns a boolean.
- tests.test_git_ops.test_is_version_bump_allowed_invalid_part()[source]ΒΆ
Test that is_version_bump_allowed raises for invalid parts.
- tests.test_git_ops.test_is_version_bump_allowed_current_repo()[source]ΒΆ
Test the version bump check logic against the current repository state.
This test verifies the correct behavior based on comparing current version in pyproject.toml against the latest Git tag.
- tests.test_git_ops.test_is_version_bump_allowed_uses_commit_fallback(monkeypatch, current, released, part, allowed)[source]ΒΆ
With no tag reachable, the verdict comes from the release commit.
The release workflow pushes its tag after the bump job starts, so a shallow clone or a plain race leaves
get_latest_tag_versionempty. Parsing the release commit is what keeps the guard working through that window; without the fallback the check fails open and allows a double increment.
- tests.test_git_ops.test_is_version_bump_allowed_without_tags_or_commits(monkeypatch)[source]ΒΆ
Nothing to compare against fails open, so a release is never blocked.
- tests.test_git_ops.test_branch_cycle_publishes_and_restores(git_workdir)[source]ΒΆ
A publish leaves the remote updated and the checkout exactly as found.
- tests.test_git_ops.test_discard_changes_drops_what_a_failed_commit_staged(git_workdir)[source]ΒΆ
The index goes back to
HEADwith the tree, untracked files aside.An updater whose commit fails after its
git addleaves its diff staged. Restored from the index alone, the tree would keep that diff, and the whole-tree stage of the next updater would publish it in its own pull request.
- tests.test_git_ops.test_changed_paths_lists_what_a_reset_would_discard(git_workdir)[source]ΒΆ
Staged and unstaged changes count, a rename as its two paths.
An untracked file is no change: no reset to
HEADtouches it.
- tests.test_git_ops.test_stage_all_pathspec_leaves_everything_else_dirty(git_workdir)[source]ΒΆ
A scoped stage commits its pathspec and nothing else.
The case that needs it: a job installing its own tooling into the checkout, where the whole-tree default would publish the installation alongside the output. Anything outside the pathspec stays in the working tree, so it goes away with the throwaway branch instead of into the pull request.
- tests.test_git_ops.test_commit_tracked_leaves_untracked_files_out(git_workdir)[source]ΒΆ
Only tracked files enter the commit, authored by the CI bot.
The release commits carry what the freeze edited: a file a tool left in the checkout must not ride along into a published tag.
- tests.test_git_ops.test_commit_tracked_refuses_an_empty_commit(git_workdir)[source]ΒΆ
A freeze that changed nothing is an error, never an empty release commit.
- tests.test_git_ops.test_stage_all_pathspec_matching_nothing_reports_no_work(git_workdir)[source]ΒΆ
A pathspec no dirty file matches is not a commit waiting to happen.
- tests.test_git_ops.test_stage_all_stale_pathspec_does_not_cost_the_others(git_workdir)[source]ΒΆ
One unresolvable entry no longer takes the whole staging down with it.
git addrefuses the entire invocation on its first unmatched pathspec, so an allowlist naming output a run happened not to produce would stage nothing rather than stage the rest.
- tests.test_git_ops.test_rebuilding_the_same_output_yields_the_same_tree(git_workdir)[source]ΒΆ
The comparison that keeps an unchanged job from re-pushing.
- tests.test_git_ops.test_force_push_refuses_an_outdated_lease(git_workdir)[source]ΒΆ
A branch that moved since the caller looked is not silently overwritten.
- tests.test_git_ops.test_force_push_tells_a_lost_lease_from_other_failures(git_workdir)[source]ΒΆ
A push failing for another reason than a moved branch is no lost lease.
- tests.test_git_ops.test_force_push_rejection_carries_stderr(git_workdir, caplog)[source]ΒΆ
A rejected push raises with gitβs stderr, and logs nothing on its own.
- tests.test_git_ops.test_branch_deletion_is_idempotent(git_workdir)[source]ΒΆ
Both deletions tolerate a branch that is already gone.
- tests.test_git_ops.test_rebase_onto_replays_carried_commits(git_workdir, tmp_path)[source]ΒΆ
The moved-base path: two job commits land on the newer base intact.
- tests.test_git_ops.test_rebase_onto_reports_a_conflict_without_leaving_one_behind(git_workdir)[source]ΒΆ
A conflicting replay aborts cleanly, leaving the branch usable as-is.
- tests.test_git_ops.test_restore_paths_carries_a_file_without_moving_head(git_workdir)[source]ΒΆ
A path travels from a branch while the checkout keeps its own tree.
The property the sampling lane depends on: a job reads its accumulating store back from an open pull request and still runs the code of the branch it was called on.