Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add submodules support on GitHub through graphql api #9996

Open
Dynesshely opened this issue Feb 27, 2024 · 5 comments
Open

Add submodules support on GitHub through graphql api #9996

Dynesshely opened this issue Feb 27, 2024 · 5 comments
Labels
service-badge Accepted and actionable changes, features, and bugs

Comments

@Dynesshely
Copy link

馃搵 Description

Currently, more and more projects use git submodules to split the project architecture, leaving an almost empty main repository (almost only references to submodules)

However, when counting data such as repo size/code size/comments, shields does not take the data of submodules into consideration.

Currently, GitHub GraphQL Api can already query submodules under a warehouse.
As long as the recursive search (specifying the front depth) is required, a submodule tree of the warehouse can be constructed.
The shields (repo size, etc.) mentioned above can be more accurate. (Of course, we may have to verify that the repositories belong to the same owner)

Take my own repo for example:

image

@Dynesshely
Copy link
Author

For some shields that can introduce this function, we can add (bool) includingSubmodules argument.

@chris48s
Copy link
Member

A slight issue here is that the submodule object isn't a full repository object. It only exposes quite a limited number of properties.

https://docs.github.com/en/graphql/reference/objects#submodule

  • branch
  • gitUrl
  • name
  • nameRaw
  • path
  • pathRaw
  • subprojectCommitOid

As far as I can tell, things like size, languages etc can't be fetched for all submodules in a single query, so we'd have to make a second round-trip to fetch the details for submodules. With the GraphQL API we could at least query the data for all submodules at once in a second query.

I think I'd want include_submodules to be an optional param which is off by default.

Which badges are you thinking this would apply to?

@chris48s chris48s added the service-badge Accepted and actionable changes, features, and bugs label Feb 27, 2024
@Dynesshely
Copy link
Author

A slight issue here is that the submodule object isn't a full repository object. It only exposes quite a limited number of properties.

https://docs.github.com/en/graphql/reference/objects#submodule

  • branch
  • gitUrl
  • name
  • nameRaw
  • path
  • pathRaw
  • subprojectCommitOid

As far as I can tell, things like size, languages etc can't be fetched for all submodules in a single query, so we'd have to make a second round-trip to fetch the details for submodules. With the GraphQL API we could at least query the data for all submodules at once in a second query.

I think I'd want include_submodules to be an optional param which is off by default.

Which badges are you thinking this would apply to?

As you said, it does require a second query to get the exact information, but I think it is worth it. Of course, in order to relieve the pressure on the server, this attribute should be turned off by default.

I think this property can be applied to the following shield first:

@chris48s
Copy link
Member

@Dynesshely
Copy link
Author

Not sure about stars. If I make a repo and pull in https://github.com/freeCodeCamp/freeCodeCamp as a submodule, my repo now has >300k stars? 馃槃

We could only count submodules' stars when they are owned by same owner, which could be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

No branches or pull requests

2 participants