awslabs / git-remote-s3

Apache License 2.0
489 stars 8 forks source link

UnboundLocalError: local variable 'sha' referenced before assignment #17

Closed hieuhtr closed 1 week ago

hieuhtr commented 1 week ago

I'm using this tool for backup/mirror current repo to S3. My flow is pretty simple

git clone --mirror git@bitbucket.org:example/alice
cd ./alice.git
git remote set-url --push origin s3://example-bitbucket-backup/project/alice.git
git fetch -p origin
git push --mirror

If it's first one, everything is fine. There is no failure.

But on second run, it returns failure, but sometimes, it's not. Failure rate likely over 90%.

fatal: ambiguous argument '': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-s3", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/git_remote_s3/remote.py", line 303, in main
    s3remote.process_cmd(line)
  File "/usr/local/lib/python3.9/site-packages/git_remote_s3/remote.py", line 275, in process_cmd
    push_res = [self.cmd_push(c) for c in self.push_cmds]
  File "/usr/local/lib/python3.9/site-packages/git_remote_s3/remote.py", line 275, in <listcomp>
    push_res = [self.cmd_push(c) for c in self.push_cmds]
  File "/usr/local/lib/python3.9/site-packages/git_remote_s3/remote.py", line 152, in cmd_push
    if os.path.exists(f"{temp_dir}/{sha}.bundle"):
UnboundLocalError: local variable 'sha' referenced before assignment
error: failed to push some refs to 's3://example-bitbucket-backup/project/alice.git'

Is there anything wrong on my local machine?

I'm using Mac python3.9 and latest git-remote-s3 as installed step

hieuhtr commented 1 week ago

Looks like issue is coming from having another object path

s3://example-bitbucket-backup/project/alice.git

I retry with dropping path, so far all good. Hope so!

s3://example-bitbucket-backup/alice.git