Opened 3 years ago

Support for git submodules

Reported by: Owned by: Lele Gaifax Jun Omae normal TracPygit2Plugin normal

Description

Right now when a git repository contains submodules, the plugin raises an internal error in GitNode.__init__() because git_repos.get() returns None for those entries.

I know that there's already a Trac ticket about this, but I wonder if it would be reasonable to handle the case without raising an error in the meantime, for example

• tracext/pygit2/git_fs.py

 if tree_entry is None: raise NoSuchNode(path, rev) git_object = repos.git_repos.get(tree_entry.oid) if git_object.type == GIT_OBJ_TREE: if git_object is None and oct(tree_entry.filemode).startswith('016'): kind = Node.DIRECTORY git_object = None tree = None blob = None elif git_object.type == GIT_OBJ_TREE: kind = Node.DIRECTORY tree = git_object blob = None elif git_object.type == GIT_OBJ_BLOB: return annotations def get_entries(self): if self.commit is None or not self.isdir: if self.commit is None or not self.isdir or ( self.tree is None and oct(self.tree_entry.filemode).startswith('016')): return repos = self.repos

Ideally, such nodes could return a property (say 'hint') with This is the mount point of a git submodule...

What do you think?

comment:1 Changed 3 years ago by Jun Omae

In 13908:

TracPygit2Plugin: avoid NoSuchNode exceptions for submodule'd entry in GitNode.__init__ (refs #11732)

comment:2 in reply to:  description Changed 3 years ago by Jun Omae

Would you please try the latest?

Ideally, such nodes could return a property (say 'hint') with This is the mount point of a git submodule...

Yes. It would be good to provide information for the submodule'd entry by your suggestion or like [svn:externals].

Last edited 3 years ago by Jun Omae (previous) (diff)

comment:3 Changed 3 years ago by Lele Gaifax

And yes, it would be great if we could map the mount point to an arbitrary URL: in my case most of them would be a redirect to the same Trac instance.

I think that the trickiest part is the configuration section... I mean, in the most general case where you have multiple repositories you want to discriminate between repo A's /src/submodule and repo B's /src/submodule, that may point to the same external product but at different revisions... For example, in my own use case, the Trac instance tracks several "forks" of the same product made by different peoples (very like Trac's cboos.git and jomae.git).

I will try to understand the logic behind [svn:externals] and if pygit2 provides some kind of interface to .gitmodules maybe I'll be able to contribute some code, or at least ideas :-)

Modify Ticket

Action
as new The owner will remain Jun Omae.