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

FTP upload fails on submodules with bare proxy setup #44

Open
Janghou opened this issue Oct 7, 2011 · 4 comments
Open

FTP upload fails on submodules with bare proxy setup #44

Janghou opened this issue Oct 7, 2011 · 4 comments

Comments

@Janghou
Copy link

Janghou commented Oct 7, 2011

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

@thomasflad
Copy link

Something new here? Have the same problem ...

@ezyang
Copy link
Owner

ezyang commented Nov 23, 2012

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

@peteruhnak
Copy link
Contributor

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.

@Pimmetje
Copy link

Pimmetje commented Sep 2, 2015

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.

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

5 participants