Skip to content

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

@goetzk

Description

@goetzk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions