question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support default branch syntax in GitHub UrlReader

See original GitHub issue

Feature Suggestion

The GitHub discovery processor currently supports using - in place of the branch name to represent the default branch. For example: https://github.com/myorg/service-*/blob/-/catalog-info.yaml

The - is resolved into the actual name of the default branch by the discovery processor before it creates the child location in the catalog, which will then be used for reading the target YAML. This means that the entity location URL will in the end be set to for example https://github.com/myorg/service-foo/blob/master/catalog-info.yaml. This then triggers a conflict if you ever rename the default branch, since for example https://github.com/myorg/service-foo/blob/main/catalog-info.yaml is considered a different location. You then need to delete the original entity before the new location is picked up, as discussed in #9030.

I think we can solve this by keeping the - in place in the location URL, and instead power up GithubUrlReader.readUrl to support that syntax.

Possible Implementation

We think this is a good first issue and would be happy if anyone from the community wants to pick this up! ❤️

On the UrlReader side it should be enough to switch out this to not pass any ref query param if the ref is '-'.

In the discovery processor it should be enough to remove this logic and pass through the - in the URL instead. It is probably best to keep the check that makes sure that the repository has a default branch when using - as well.

These are pretty small changes, but we’d want to spend some time verifying that this all works as intended, allowing switching out the default branch and so on. One important thing to verify and possibly work around is to make sure that this doesn’t have a negative impact on existing catalogs that currently use GitHub discovery.

Context

#9030

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
devthcommented, Feb 11, 2022

Sounds good! I’ll look into the git-url-parse issue later. I could wait till that’s resolved, or let me know if there’s help wanted on that too.

1reaction
Rugvipcommented, Feb 11, 2022

@devth good catch, thanks, updated 😁

And alright thank you for the heads up! Being able to properly parse the URL would be part of implementing this as well then. Can say that we’re aiming to move away from git-url-parse though (#9095)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get the default branch name of git projects - Stack Overflow
For a source code downloaded by repo init and repo sync , all projects and their branches are described in the manifest file...
Read more >
The default branch for newly-created repositories is now main
This change is one of many changes GitHub is making to support projects and maintainers that want to rename their default branch.
Read more >
Master vs Main. Default branching your new ServiceNow App ...
Historically speaking, the default branch used by Git DVCS tool's was set to master. Every Git repository had a master branch unless a ......
Read more >
Git Feature Branch Workflow | Atlassian Git Tutorial
It also means the main branch will never contain broken code, ... Git Feature Branch Workflow is branching model focused, meaning that it...
Read more >
How do I change the Git default branch name for ... - SESYNC
This FAQ will help you set the default name in your own git ... Use the move command in Git to copy the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found