Skip to content

git.repo fails when a tag is checked out #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
goetzk opened this issue Apr 15, 2025 · 1 comment · Fixed by #1343
Closed

git.repo fails when a tag is checked out #1340

goetzk opened this issue Apr 15, 2025 · 1 comment · Fixed by #1343

Comments

@goetzk
Copy link
Contributor

goetzk commented Apr 15, 2025

Describe the bug

Running this twice:

headscale_admin_git_repo = 'https://github.com/GoodiesHQ/headscale-admin'
headscale_admin_code_path = '/srv/headscale_admin'
headscale_admin_git_branch = 'v0.25.6'

# Set up headscale-admin GUI
git.repo(
  name='Clone Headscale-admin git repository',
  src=headscale_admin_git_repo,
  dest=headscale_admin_code_path,
  branch=headscale_admin_git_branch,
) 

When the repo is cloned for the first time using git.repo it works. On the second run we have the error below:

--> Starting operation: Clone Headscale-admin git repository 
    [wireguard-ui-trial]      You are not currently on a branch.
    [wireguard-ui-trial]      Please specify which branch you want to merge with.
    [wireguard-ui-trial]      See git-pull(1) for details.
    [wireguard-ui-trial]      
    [wireguard-ui-trial]          git pull <remote> <branch>
    [wireguard-ui-trial]      
    [wireguard-ui-trial]      Error: executed 0 commands

To Reproduce

Steps to reproduce the behavior, please include where possible:

  • Operation code & usage
  • Target system information
  • Example using the @docker connector (helps isolate the problem)
$ pip list |grep pyi
pyinfra             3.2

command:

$ pyinfra ./inventory-headscale.py ./deploy_headscale.py -y -vv --limit wireguard-ui-trial
[other operations]

First time:

--> Starting operation: Clone Headscale-admin git repository 
[wireguard-ui-trial]      >>> sh -c '! (test -e /srv/headscale_admin || test -L /srv/headscale_admin ) || ( stat -c '"'"'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N'"'"' /srv/headscale_admin 2> /dev/null || stat -f '"'"'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY'"'"' /srv/headscale_admin )'
    [wireguard-ui-trial]      Loaded fact files.Directory (path=/srv/headscale_admin)
[wireguard-ui-trial]      >>> sh -c 'mkdir -p /srv/headscale_admin'
[wireguard-ui-trial]      >>> sh -c '! (test -e /srv/headscale_admin/.git || test -L /srv/headscale_admin/.git ) || ( stat -c '"'"'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N'"'"' /srv/headscale_admin/.git 2> /dev/null || stat -f '"'"'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY'"'"' /srv/headscale_admin/.git )'
    [wireguard-ui-trial]      Loaded fact files.Directory (path=/srv/headscale_admin/.git)
[wireguard-ui-trial]      >>> sh -c 'cd /srv/headscale_admin && git clone https://github.com/GoodiesHQ/headscale-admin --branch v0.25.6 .'
    [wireguard-ui-trial]      Success

second time:

--> Starting operation: Clone Headscale-admin git repository 
[wireguard-ui-trial]      >>> sh -c '! (test -e /srv/headscale_admin || test -L /srv/headscale_admin ) || ( stat -c '"'"'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N'"'"' /srv/headscale_admin 2> /dev/null || stat -f '"'"'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY'"'"' /srv/headscale_admin )'
    [wireguard-ui-trial]      Loaded fact files.Directory (path=/srv/headscale_admin)
    [wireguard-ui-trial]      noop: directory /srv/headscale_admin already exists
[wireguard-ui-trial]      >>> sh -c '! (test -e /srv/headscale_admin/.git || test -L /srv/headscale_admin/.git ) || ( stat -c '"'"'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N'"'"' /srv/headscale_admin/.git 2> /dev/null || stat -f '"'"'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY'"'"' /srv/headscale_admin/.git )'
    [wireguard-ui-trial]      Loaded fact files.Directory (path=/srv/headscale_admin/.git)
[wireguard-ui-trial]      >>> sh -c '! command -v git >/dev/null || ! test -d /srv/headscale_admin || (cd /srv/headscale_admin && git describe --all)'
    [wireguard-ui-trial]      Loaded fact git.GitBranch (repo=/srv/headscale_admin)
[wireguard-ui-trial]      >>> sh -c 'cd /srv/headscale_admin && git pull'
    [wireguard-ui-trial]      You are not currently on a branch.
    [wireguard-ui-trial]      Please specify which branch you want to merge with.
    [wireguard-ui-trial]      See git-pull(1) for details.
    [wireguard-ui-trial]      
    [wireguard-ui-trial]          git pull <remote> <branch>
    [wireguard-ui-trial]      
    [wireguard-ui-trial]      Error: executed 0 commands

--> Disconnecting from hosts...
--> pyinfra error: No hosts remaining!

Expected behavior

A clear and concise description of what you expected to happen.

Not sure the correct solution, perhaps one of:

  • 'pull' is described more completely in documentation
  • when a tag is checked out skip the pull (?)

I think the first probably.

@wowi42
Copy link
Contributor

wowi42 commented Apr 24, 2025

@goetzk fixed

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 a pull request may close this issue.

2 participants