Skip to content

git.repo does not honor change of src #1763

@pascal-cm

Description

@pascal-cm

Describe the bug

When changing src of git.repo for an existing working copy, the new value of src is not assigned to the working copy's origin.

Consequently, after switching to a remote with newer commits, those are not present in the working copy.

To Reproduce

# File: git_repo_does_not_honor_change_of_src.py

from pyinfra.operations import git
from os import path

tmp_dir = "/tmp/git_repo_does_not_honor_change_of_src"
repo_original = "https://github.com/ansible/ansible"
repo_changed = "https://github.com/pyinfra-dev/pyinfra.git"

git.repo(dest=tmp_dir, src=repo_original)

git.repo(dest=tmp_dir, src=repo_changed)
# Run commands

uv run pyinfra @local git_repo_does_not_honor_change_of_src.py
(cd /tmp/git_repo_does_not_honor_change_of_src && git remote -v) # Still Ansible :(

Expected behavior

The repository's origin is updated to src, with new commits visible. (Above example doesn't make sense as there is no common ancestry or set of files.)

Meta

Pyinfra 3.8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugLabel for all kind of bugs.new featureoperationsIssues with operations.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions