pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.91k stars 382 forks source link

git pull returns Success when already has all changes #994

Open fimdomeio opened 1 year ago

fimdomeio commented 1 year ago

Describe the bug

When pulling from a git repository it outputs the Success state in situations where it should output No Changes

debug output:

[lima] >>> sh -c 'cd /home/fimdomeio.linux/src/neovim && git pull'
[lima] Already up to date.

To Reproduce

pull from a repo.

I'm running this operation:

git.repo(
    name="pull from neovim repo",
    src="https://github.com/neovim/neovim", 
    dest="/home/fimdomeio.linux/src/neovim", 
)

operating system is a Ubuntu Virtual Machine (Ubuntu 23.04)

Expected behavior

I expect "No changes" as a Status

Meta

pyinfra --support

  System: Darwin
      Platform: macOS-13.4.1-arm64-arm-64bit
      Release: 22.5.0
      Machine: arm64
    pyinfra: v2.7
    Executable: /Users/fimdomeio/.local/bin/pyinfra
    Python: 3.11.4 (CPython, Clang 14.0.3 (clang-1403.0.22.14.1))

installed with pipx

Fizzadar commented 11 months ago

The “success” bit is determined as “did run any commands”, in the case of git it the “git pull” command. I think this is correct (it did run, it did succeed), pyinfra is thinking on the command level rather than git itself.

We could, I think, use git fetch to pre-check for changes and only pull if so which would resolve this, though I’m not sure in reality if this is a problem?