You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When viewing ADRs in the log4brains web presentation (preview or live on gitlab / github pages), clicking on the "View in gitlab button" () leads to a 404 page.
This is due to the fact that my repository's default branch (such as any recent new repos on gitlab/github) is called main and there exists no master-branch.
Steps to Reproduce
Initialize a repository whose default branch is not named master
Set up ADR management with log4brains
Start up the preview server and/or publish via gitlab / github pages
Call up the knowledge base in the browser and click the aforementioned button in the right upper corner of any ADR
Expected Behavior
It should not lead to a 404 page and instead show the ADR as commited into the repository.
Environment
Log4brains version: 1.0.0-beta.11
Node.js version: v17.3.0.
OS and its version: Manjaro linux / whatever gitlab.com uses
Browser information: Firefox
Possible Solution
There is already a TODO comment in adr-transformers.ts. Making it configurable would be a nice-to-have feature addition, however it may not be needed to fix this bug for now. For instance, i do not have any repository url configured in .log4brains.yml – nevertheless log4brains correctly guesses the repository origin (pretty impressive btw 👏). I assume this magic happens somewhere in guessGitRepositoryConfig.ts.
Dirty fix
The details in guessGitRepositoryConfig.ts are currently a bit over my head, however it could simply check if a master branch exists at all, and if it doesn't, check for main. Having said that, as the whole industry is shifting towards calling the default branch main, so that should be checked first i guess.
Better fix
As far as my research and quick tests show, git remote show origin should reliably print the default HEAD branch .
Using git remote show origin | grep 'HEAD branch' | cut -d' ' -f5 in the extracts the name straightaway, though that cryptic foo is better of done in clean coded type script 😉
The text was updated successfully, but these errors were encountered:
Bug Report
Description
When viewing ADRs in the log4brains web presentation (preview or live on gitlab / github pages), clicking on the "View in gitlab button" () leads to a 404 page.
This is due to the fact that my repository's default branch (such as any recent new repos on gitlab/github) is called
main
and there exists nomaster
-branch.Steps to Reproduce
master
Expected Behavior
It should not lead to a 404 page and instead show the ADR as commited into the repository.
Environment
Possible Solution
There is already a TODO comment in adr-transformers.ts. Making it configurable would be a nice-to-have feature addition, however it may not be needed to fix this bug for now. For instance, i do not have any repository url configured in
.log4brains.yml
– nevertheless log4brains correctly guesses the repository origin (pretty impressive btw 👏). I assume this magic happens somewhere inguessGitRepositoryConfig.ts
.Dirty fix
The details in
guessGitRepositoryConfig.ts
are currently a bit over my head, however it could simply check if amaster
branch exists at all, and if it doesn't, check formain
. Having said that, as the whole industry is shifting towards calling the default branchmain
, so that should be checked first i guess.Better fix
As far as my research and quick tests show,
git remote show origin
should reliably print the default HEAD branch .Using
git remote show origin | grep 'HEAD branch' | cut -d' ' -f5
in the extracts the name straightaway, though that cryptic foo is better of done in clean coded type script 😉The text was updated successfully, but these errors were encountered: