Modify

Opened 11 years ago

Last modified 11 years ago

#11732 new defect

Support for git submodules

Reported by: Lele Gaifax Owned by: Jun Omae
Priority: normal Component: TracPygit2Plugin
Severity: normal Keywords:
Cc: Trac Release:

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

     
    952952                if tree_entry is None:
    953953                    raise NoSuchNode(path, rev)
    954954                git_object = repos.git_repos.get(tree_entry.oid)
    955             if git_object.type == GIT_OBJ_TREE:
     955            if git_object is None and oct(tree_entry.filemode).startswith('016'):
    956956                kind = Node.DIRECTORY
     957                git_object = None
     958                tree = None
     959                blob = None
     960            elif git_object.type == GIT_OBJ_TREE:
     961                kind = Node.DIRECTORY
    957962                tree = git_object
    958963                blob = None
    959964            elif git_object.type == GIT_OBJ_BLOB:
     
    10461051        return annotations
    10471052
    10481053    def get_entries(self):
    1049         if self.commit is None or not self.isdir:
     1054        if self.commit is None or not self.isdir or (
     1055                self.tree is None and
     1056                oct(self.tree_entry.filemode).startswith('016')):
    10501057            return
    10511058
    10521059        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?

Attachments (0)

Change History (3)

comment:1 Changed 11 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 11 years ago by Jun Omae

Would you please try the latest?

Replying to lgaifax:

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 11 years ago by Jun Omae (previous) (diff)

comment:3 Changed 11 years ago by Lele Gaifax

Thanks again: latest version seems working great indeed!

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

Change Properties
Set your email in Preferences
Action
as new The owner will remain Jun Omae.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.