Edgewall Software
Modify

Opened 7 years ago

Closed 12 months ago

#10603 closed enhancement (fixed)

GitPlugin: Support for submodules

Reported by: Peter Suter Owned by: Jun Omae
Priority: low Milestone: 1.0.17
Component: plugin/git Version: 1.0dev
Severity: normal Keywords: subrepository git-submodule
Cc: lele@…, Jun Omae
Release Notes:

Support submodule entries in Git repository.

API Changes:

Description

Created as part of the move of GitPlugin. Tickets originally reported for th:GitPlugin: th:#8880, th:#3842

Quoting mresnick:

Is anyone working on submodule support in the source browser ?

From the git_fs.py file:

pass # FIXME: this is a workaround for missing git submodule support in the plugin

Particularly for TRAC 0.12 which supports multiple repositories it should be possible to switch context to display submodule files.

Quoting anonymous:

Error[1] apears when change contains only submodule version update. Same error can be reproduced when change contains information about merge branch into master.

[1] TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

Attachments (0)

Change History (15)

comment:1 Changed 7 years ago by anonymous

Is this going to get implemented at some point?

comment:2 Changed 7 years ago by Christian Boos

Well, we can't do much until someone contributes a repository icon ;-)

comment:3 in reply to:  description Changed 6 years ago by Peter Suter

Quoting anonymous:

Error[1] apears when change contains only submodule version update. Same error can be reproduced when change contains information about merge branch into master.

[1] TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

This part is a duplicate of #10162.

comment:4 Changed 6 years ago by Peter Suter

Keywords: subrepository added

But as comment:3:ticket:10162 suggests, maybe we can for now treat subrepositories as directories. Changing GitRepository.get_changes() and GitChangeset.get_changes() from everything except directories are files to the reverse perhaps?

kind = Node.DIRECTORY
if mode2.startswith('10') or mode1.startswith('10'):
    kind = Node.FILE

(untested)

comment:5 Changed 6 years ago by Christian Boos

Milestone: next-major-releases
Priority: normallow
Version: 1.0dev

comment:6 Changed 6 years ago by Jun Omae

#11183 was closed as duplicate.

comment:7 Changed 5 years ago by Lele Gaifax

Cc: lele@… added

here is another possible workaround to the problem.

comment:8 Changed 5 years ago by Jun Omae

Cc: Jun Omae added
Keywords: git-submodule added
Milestone: next-major-releasesnext-stable-1.0.x

comment:9 Changed 2 years ago by Ryan J Ollos

Milestone: next-stable-1.0.xnext-stable-1.2.x

Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.

comment:10 Changed 12 months ago by Jun Omae

I got TypeErrors under production environment. At least, I think we should prevent the TypeErrors even if #10162 is not resolved.

comment:11 Changed 12 months ago by Jun Omae

Milestone: next-stable-1.2.x1.0.17
Owner: set to Jun Omae
Status: newassigned

Proposed changes in [5148072ee/jomae.git] (jomae.git@t10603).

comment:12 Changed 12 months ago by Jun Omae

Reconsidering, submodule'd entry should be a directory. In proposed changes, that would be a file.

$ git submodule add -b 1.0-stable --name trac git@github.com:edgewall/trac.git trac
Cloning into 'trac'...
remote: Counting objects: 96491, done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 96491 (delta 18), reused 17 (delta 8), pack-reused 96439
Receiving objects: 100% (96491/96491), 35.90 MiB | 54.00 KiB/s, done.
Resolving deltas: 100% (76657/76657), done.
Checking connectivity... done.
$ git commit -a -m 'add submodule'
[master (root-commit) a35122f40] add submodule
 2 files changed, 5 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 trac
$ git archive --format=tar --prefix=./ HEAD | tar tvf -
drwxrwxr-x root/root         0 2017-12-11 12:05 ./
-rw-rw-r-- root/root        93 2017-12-11 12:05 ./.gitmodules
drwxrwxr-x root/root         0 2017-12-11 12:05 ./trac/           # <== directory

I'll re-propose changes.

Last edited 12 months ago by Jun Omae (previous) (diff)

comment:13 Changed 12 months ago by Jun Omae

Proposed changes in [ab9e4aaa8/jomae.git] (jomae.git@t10603.1), again.

In the changes, GitNode.kind for submodule'd entry is Node.DIRECTORY and referenced sha in the submodule is stored in commit of GitNode.properties().

>>> from trac.env import Environment
>>> from trac.versioncontrol.api import RepositoryManager
>>> env = Environment('/dev/shm/tracenv')
>>> rm = RepositoryManager(env)
>>> repos = rm.get_repository('')
>>> node = repos.get_node('/sub')
>>> node.kind
'dir'
>>> node.get_properties()
{'commit': 'c392cf2e6a537dc3efe797576efad365a0fbeade', 'mode': '160000'}
>>> node.get_content() is None
True
>>> node.get_content_length() is None
True

comment:14 in reply to:  13 Changed 12 months ago by Jun Omae

Replying to Jun Omae:

Proposed changes in [ab9e4aaa8/jomae.git] (jomae.git@t10603.1), again.

Revised the branch. Fixed GitNode.get_entries() returns a list included itself.

comment:15 Changed 12 months ago by Jun Omae

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [16409] and merged in [16410-16411].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.