Docs feedback: Find projects using old master nomenclature
Documentation page
https://docs.gitlab.com/ee/user/project/repository/branches/default.html
Goal
Identify which projects are still using the old master
nomenclature in order to change them to main.
Problem to solve
After we made the change from 'master' to 'main' in GL14.0 customers may want to easily see which projects are still using the old master nomenclature so they can change those projects to main but don't have a method.
In order to do this you'd need to do one of the following options
Option 1
- Obtain a list of projects with the Projects API https://docs.gitlab.com/ee/api/projects.html
- Iterate through each project.
- Each project returned has useful fields:
-
default_branch
(see if it'smaster
!) -
web_url
(for building a list of what to edit)
-
Depending on how big your data set is, that might be enough. However, if you needed to go further, maybe you could take the project ID and then tap into the https://docs.gitlab.com/ee/api/members.html members API to identify users with maintainer or owner access?
Option 2
After reading this and doing some more researching, the docs suggest this API would work: https://docs.gitlab.com/ee/api/branches.html and It's probably best in GraphQL
{
group(fullPath: "GROUPNAME") {
projects {
nodes {
name
repository {
rootRef
}
}
}
}
}
This query should do the trick. You can test it out against gitlab-org
to see what kinds of results you get by visiting https://gitlab.com/-/graphql-explorer and replacing gitlab-org
as the fullPath
argument. You can add pageInfo
to the query to be able to page through result sets (100 at a time by default).
{
group(fullPath: "GROUPNAME") {
projects(after: null) {
pageInfo {
hasNextPage
endCursor
}
nodes {
name
repository {
rootRef
}
}
}
}
}
Replacing after: null
with after: "<endCursor>"
to page the results.
Next Steps
-
I'll create an MR for change if we think this is valuable.