Skip to content
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

Cloning into bare git repo fails #5

Closed
Grokzen opened this issue Mar 25, 2020 · 2 comments
Closed

Cloning into bare git repo fails #5

Grokzen opened this issue Mar 25, 2020 · 2 comments

Comments

@Grokzen
Copy link
Collaborator

Grokzen commented Mar 25, 2020

It is currently not possible to add a repo that is bare and dont have any refs on the remote side. It fails out with the error fatal: Remote branch master not found in upstream origin

Investigate if it is possible to determine if the repo is bare or not. Otherwise a new solution has to be thought up on how to deal with this case as it must be supported.

@holmboe
Copy link
Contributor

holmboe commented May 14, 2020

DEBUG: Repo update - all
Are you sure you want to update the following repos "myrepo"
(y/n) << y
Traceback (most recent call last):
  File "/home/nn/code/foobar/sgit/sgit/core.py", line 260, in update
    branch=revision['branch'],
  File "/home/nn/code/foobar/sgit/.venv/lib/python3.6/site-packages/git/repo/base.py", line 1017, in clone_from
    return cls._clone(git, url, to_path, GitCmdObjectDB, progress, multi_options, **kwargs)
  File "/home/nn/code/foobar/sgit/.venv/lib/python3.6/site-packages/git/repo/base.py", line 958, in _clone
    finalize_process(proc, stderr=stderr)
  File "/home/nn/code/foobar/sgit/.venv/lib/python3.6/site-packages/git/util.py", line 328, in finalize_process
    proc.wait(**kwargs)
  File "/home/nn/code/foobar/sgit/.venv/lib/python3.6/site-packages/git/cmd.py", line 408, in wait
    raise GitCommandError(self.args, status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git clone --branch=master -v git@gitlab.com:foobar/myrepo.git /home/nn/code/foobar/sysrepo/myrepo
  stderr: 'Cloning into '/home/nn/code/foobar/sysrepo/myrepo'...
fatal: Remote branch master not found in upstream origin
fatal: the remote end hung up unexpectedly
'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nn/code/foobar/sgit/sgit/cli.py", line 185, in cli_entrypoint
    exit_code = run(cli_args, sub_args)
  File "/home/nn/code/foobar/sgit/sgit/cli.py", line 171, in run
    retcode = core.update(repo)
  File "/home/nn/code/foobar/sgit/sgit/core.py", line 264, in update
    raise SgitException(f'Clone "{name}" failed, exception: {e}')
sgit.exceptions.SgitException: Clone "myrepo" failed, exception: Cmd('git') failed due to: exit code(128)
  cmdline: git clone --branch=master -v git@gitlab.com:foobar/myrepo.git /home/nn/code/foobar/sysrepo/myrepo
  stderr: 'Cloning into '/home/nn/code/foobar/sysrepo/myrepo'...
fatal: Remote branch master not found in upstream origin
fatal: the remote end hung up unexpectedly
'
> /home/nn/code/foobar/sgit/sgit/core.py(264)update()
-> raise SgitException(f'Clone "{name}" failed, exception: {e}')

@Grokzen
Copy link
Collaborator Author

Grokzen commented Jan 24, 2022

With the following .sgit.yml file

repos:
  bare:
    clone-url: git@gitlab.com:dynamist/sgit-bare-repo.git
    revision:
      branch: master

you will get the following output from the initial update and future updates

(sgit) ➜  sgit git:(master) ✗ DEBUG=1 PDB=1 sgit -y update
DEBUG: Repo update - None
Are you sure you want to update the following repos "bare"
INFO: Automatically answer yes to question
Successfully cloned into bare git repo "bare" from remote server

(sgit) ➜  sgit git:(master) ✗ sgit update
DEBUG: Repo update - None
Are you sure you want to update the following repos "bare"
(y/n) << y
TODO: Parse for any changes...
DEBUG: Handling branch update case
Exception type : BadName
EXCEPTION MESSAGE: Ref 'origin/master' did not resolve to an object
To get more detailed exception set environment variable 'DEBUG=1'
To PDB debug set environment variable 'PDB=1'

Note that it is intended for the second sgit update to fail as the remote branch origin/master do not yet exists in a bare git repo.

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

No branches or pull requests

2 participants