Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Submodule support / used-in data available?

Marko Tomljenovic June 4, 2018

Hello,

we are potentially thinking about using GIT submodules in a large number of repositories.

For doing this successfully we would need a functionality that allows us to find out in which repositories/tags a specific repository in a specific version (either HEAD or a tag) is integrated as a submodule.

Does Bitbucket keep track of such information and can it be queried via some sort of API?

And in general what kind of support (API or client side) does Bitbucket offer for GIT submodules? I did not find much in the official documentation. I only found something in the Stash documentation telling that submodules are recognized and shown in the web UI when browsing a repository.

1 answer

0 votes
Aaron
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 11, 2018

Hello Marko,

 

Welcome to the Atlassian Community!

 

I did a bit of testing on this with a Bitbucket 5.11.1 instance. When you have a submodule in a repository, you will see a small folder in a folder icon next to the directory that is a submodule. Also, next to the name of that directory/submodule, you will see the commit hash where the submodule was created from. You can click on it to be taken to the repository where the submodule was created at the commit hash of what is being used in the parent repository. 

In terms of the API, we have a full list of API here, but from what I can tell, there isn't a clear and easy way to get all of that information at once (I assume that is what you are going for). I also don't think you need the API for this. If I understand what you need correctly, Git has all of this information and Bitbucket Server is simply reading it. I'm not entirely sure all of the commands you need for the information you want, but I think the Git submodule documentation and this StackOverflow thread is a good step in the right direction.

I tailed the logs and this is what Bitbucket runs when clicking on a repository that contains a submodule:

git cat-file -t refs/heads/master:
git ls-tree -z -l refs/heads/master: --
git cat-file -p refs/heads/master:.gitmodules
git cat-file --batch

When clicking on the submodule directory itself inside that repo:

git rev-list --format=%H%x02%P%x02%aN%x02%aE%x02%at%x02%cN%x02%cE%x02%ct%n%B%n%x03END%x04 --no-walk=unsorted ee5067984f0 ee5067984f0^@ --
git rev-list --format=%H%x02%P%x02%aN%x02%aE%x02%at%x02%cN%x02%cE%x02%ct%n%B%n%x03END%x04 --no-walk=unsorted ee5067984f0821e8cdb71914192e8107808bde6c ee5067984f0821e8cdb71914192e8107808bde6c^@ --
git cat-file -t ee5067984f0821e8cdb71914192e8107808bde6c:
git ls-tree -z -l ee5067984f0821e8cdb71914192e8107808bde6c: --
git cat-file --batch

That second batch you don't really need to worry about the format so much, and the hash is the has of the submodule where it was taken from. If you need some way to automate the process, those Git commands would be another good place to start.

If I didn't completely answer your question, could you tell us your use case that we can take a look at? I'm not 100% clear on what you need to have and from where you need this information from as well as how readily available you need it. 

 

Regards,
Aaron Levinson
Dev Tools Support Engineer

Marko Tomljenovic June 13, 2018

Dear Aaron,

thanks for the comprehensive answer. You almost got my question right :)

Our use case is the following: A repository "project" contains some real files/folders but also contains a few "component" repositories that are part of the "project" via the submodule mechanism. And component repositories might have files/folder and also "module" repositories as GIT submodules. 

Using the submodule mechanism I will define project releases that are made up of component releases that are made up of module releases, etc.

That means the project hierarchy looks like this:

Project

  • Component
    • Module
  • Component
    • Module
      • Module
        • Module V2.2

 

Now in case I find out that module V2.2 is buggy, how can I find out the affected higher level (related to the above mentioned hierarchy) modules, components and repositories.

This is the crucial question for which I need to have an efficient solution for.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events