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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for default branch name #171

Merged
merged 4 commits into from
Dec 27, 2023

Conversation

jahands
Copy link
Contributor

@jahands jahands commented Dec 15, 2023

Hi! First, thanks so much for this awesome project, it's exactly what I was looking for :)

Using main as the default branch is more common now days, so I thought I would change it here.

Testing:

  • Built docker image
  • Deployed
  • Created gist
  • Cloned and confirmed the branch is main

@thomiceli
Copy link
Owner

What about adding a config variable to define the default branch name ?

Like Gitea with DEFAULT_BRANCH

@thomiceli thomiceli changed the base branch from master to dev-1.6 December 15, 2023 14:10
@jahands
Copy link
Contributor Author

jahands commented Dec 15, 2023

Good idea! Will update

@jahands
Copy link
Contributor Author

jahands commented Dec 15, 2023

Added new config: OG_GIT_DEFAULT_BRANCH and tested that it works

@jahands jahands changed the title Use branch 'main' when initializing gist repository Add config for default branch name Dec 15, 2023
Comment on lines 241 to 245
branchRe := regexp.MustCompile("^[a-z0-9-_]+$")
if !branchRe.MatchString(c.GitDefaultBranch) {
return fmt.Errorf("invalid git default branch name: %s", c.GitDefaultBranch)
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea but it kind of restrict allowed branch names with slashs or dots.
Of course almost everyone would use master or main so it's not a big deal at all, but it seems weird to me to restrict valid branches names from Git if there is a restriction in the first place.

Maybe we could remove this restriction or use a more (much) complicated regex ?

For reference : https://git-scm.com/docs/git-check-ref-format

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to prefer having input validation, but I suppose it would throw errors if an invalid branch name is specified, so removing this is probably fine.

@thomiceli
Copy link
Owner

Whoops I just realized that I did not publish the review earlier.. my bad. Anyway what do you think ?

@jahands
Copy link
Contributor Author

jahands commented Dec 27, 2023

LGTM

@thomiceli thomiceli merged commit ab2ea0a into thomiceli:dev-1.6 Dec 27, 2023
8 checks passed
thomiceli added a commit that referenced this pull request Jan 4, 2024
jiriks74 pushed a commit to jiriks74/opengist that referenced this pull request Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants