git-ftp icon indicating copy to clipboard operation
git-ftp copied to clipboard

FTP upload fails on submodules with bare proxy setup

Open Janghou opened this issue 13 years ago • 4 comments

Tried to upload, got this error;

remote: Traceback (most recent call last): remote: File "_/git-ftp.py", line 357, in remote: main() remote: File "_/git-ftp.py", line 107, in main remote: upload_diff(repo, oldtree, tree, ftp, base) remote: File "/***/git-ftp.py", line 299, in upload_diff remote: module = node.module() remote: File "/usr/local/lib/python2.6/dist-packages/GitPython-0.3.1-py2.6.egg/git/objects/submodule/util.py", line 30, in wrapper remote: raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.name) remote: git.exc.InvalidGitRepositoryError: Method 'module' cannot operate on bare repositories

Janghou avatar Oct 07 '11 14:10 Janghou

Something new here? Have the same problem ...

thomasflad avatar Nov 23 '12 08:11 thomasflad

Yeah, this is a case of "No one has written the functionality for this" yet.

ezyang avatar Nov 23 '12 16:11 ezyang

The submodules are not really stored in the bare repository, so you would need to also work with bare repository of the submodule itself and then upload it.

peteruhnak avatar Nov 23 '12 18:11 peteruhnak

For me the script would not continue. Given exception:

Traceback (most recent call last):
  File "/usr/bin/git-ftp", line 489, in <module>
    main()
  File "/usr/bin/git-ftp", line 178, in main
    upload_diff(repo, oldtree, tree, ftp, [base], patterns)
  File "/usr/bin/git-ftp", line 417, in upload_diff
    module = node.module()
  File "/usr/local/lib/python2.7/dist-packages/GitPython-1.0.1-py2.7.egg/git/util.py", line 52, in wrapper
    raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__)
git.exc.InvalidGitRepositoryError: Method 'module' cannot operate on bare repositories

I added after line 57

57: from git import Blob, Repo, Git, Submodule
58: from git.exc import InvalidGitRepositoryError

Around the codeblock on 417 i placed a try exception like

try:
    module = node.module()
    module_tree = module.commit(node.hexsha).tree
    if status == "A":
        module_oldtree = get_empty_tree(module)
    else:
        oldnode = oldtree[file]
        assert isinstance(oldnode, Submodule)  # TODO: What if not?
        module_oldtree = module.commit(oldnode.hexsha).tree
    module_base = base + [node.path]
    logging.info('Entering submodule %s', node.path)
    ftp.cwd(posixpath.join(*module_base))
    upload_diff(module, module_oldtree, module_tree, ftp, module_base, ignored)
    logging.info('Leaving submodule %s', node.path)
    ftp.cwd(posixpath.join(*base))
except InvalidGitRepositoryError:
    print "Skipping submodule"

I know it's a nasty workaround but it will do for me. If someone wants a patch u can drop me a line.

Pimmetje avatar Sep 02 '15 08:09 Pimmetje