Fail to load content of a submodule #1

Open
kkris opened this Issue Jun 8, 2011 · 7 comments

Projects

None yet

3 participants

@kkris
kkris commented Jun 8, 2011

I get this Traceback, when entering a submodule (i tried with the cream/cream repo):

Traceback (most recent call last):
  File "nano/nano.py", line 179, in __call__
    retval = callback(environ, **kwargs)
  File "/tmp/git/klaus/klaus.py", line 31, in wrapper
    **callback(env, **kwargs))
  File "/tmp/git/klaus/klaus.py", line 159, in __init__
    super(BaseRepoView, self).__init__(env)
  File "/tmp/git/klaus/klaus.py", line 122, in __init__
    self.view()
  File "/tmp/git/klaus/klaus.py", line 184, in view
    self['tree'] = self.listdir(self['path'])
  File "/tmp/git/klaus/klaus.py", line 199, in listdir
    for name, entry in self['repo'].listdir(self['commit'], path):
  File "/tmp/git/klaus/repo.py", line 89, in listdir
    tree = self.get_tree(commit, root)
  File "/tmp/git/klaus/repo.py", line 85, in get_tree
    tree = self[tree[directory][1]]
  File "/usr/lib/python2.7/site-packages/dulwich/repo.py", line 996, in __getitem__
    return self.object_store[self.refs[name]]
  File "/usr/lib/python2.7/site-packages/dulwich/repo.py", line 270, in __getitem__
    raise KeyError(name)
KeyError: '38bdce3108e1002cf4d99e44a8242f97ccd66e6c'
@jonashaag
Owner

dulwich doesn't have submodule support yet. I don't think I can fix this, but I'll try to figure out a workaround.

@jonashaag jonashaag added a commit that referenced this issue Jun 9, 2011
@jonashaag Close #2: Support for binary files, includes explicit support for ima…
…ges.

Also adds support for submodule changes in the commit diff view (#1).
Refs #3.
fba5dfe
@jonashaag
Owner

Should at least print a nice error msg.

@jonashaag
Owner

Maybe we can come up with simple submodule support. I.e. parse the .gitmodules file and "mount" the repos at the matching URL.

@jonashaag jonashaag added a commit that referenced this issue Jan 15, 2014
@jonashaag Close #2: Support for binary files, includes explicit support for ima…
…ges.

Also adds support for submodule changes in the commit diff view (#1).
Refs #3.
35dfb6c
@jonashaag jonashaag added the Dulwich label Mar 7, 2014
@jonashaag
Owner

There's a parse_submodules function now

@jelmer
Contributor
jelmer commented Jan 26, 2017

This doesn't require any further changes in Dulwich; the web UI needs to switch repository locations when it encounters a submodule.

Initial work on this can be found here:

https://github.com/jelmer/klaus/tree/submodules

This adds the right links, but it needs further work:

  • some CSS to distinguish submodules from directories
  • support for slashes in repository names (as you can see when you click on one of the submodule paths). I'm not sure how to do this with flask
@jonashaag
Owner
jonashaag commented Jan 26, 2017 edited

Cool! LGTM so far.

The problem with slashes isn't only Flask routing; it guess that shouldn't be too complicated. It's also that we don't necessarily have submodules in the internal Klaus.repos dictionary, which is a basename -> Repo object map. So if we were to use /toprepo/submodule/README.md style URLs and could figure out that this is actually accessing a file from submodule, we still wouldn't know how to resolve toprepo/submodule in the repository list, because even if submodule were in that dictionary, it would have the key submodule and not toprepo/submodule.

One solution would be to automatically add any submodules to the repository dictionary with their toprepo/submodule key, but don't show them on the repository list page. This requires to recursively look for submodules on initialisation for Smart HTTP support (unless we don't want to support Smart HTTP for submodules).

Another idea is to look for a top-level repository named submodule and assume that it must be the same as toprepo/submodule. As a sanity check, we could check if the submodule commit ID exists there. However this makes viewing different submodules with the same name impossible, unless we use a full dictionary scan for the commit ID, ignoring the repository name.

A third approach could work as follows: When initialising the repository dictionary, for each repository check if it's a submodule of another repository (this could be tricky) and add it to the repos dictionary both as submodule and toprepo/submodule. Then we could simply use the toprepo/submodule key into the dictionary list and could be sure we're getting the correct repository. We'd actually have to do this recursively for any combination of top/sub prefixes.

Not sure what's the best approach. Do you have other ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment