-
Notifications
You must be signed in to change notification settings - Fork 52
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
allow branches #34
base: master
Are you sure you want to change the base?
allow branches #34
Conversation
till
commented
Feb 5, 2023
- Chore: upgrade go to 1.19
- Chore: update actions
- Update: allow push to certain branches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments to share my thoughtprocess.
@@ -4,7 +4,7 @@ on: | |||
- push | |||
|
|||
env: | |||
GO_VERSION: 1.18 | |||
GO_VERSION: 1.19 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly updated to be able to use some functions and also, newer is better. :D
@@ -14,12 +14,12 @@ jobs: | |||
steps: | |||
|
|||
- name: Checkout code | |||
uses: actions/checkout@v2 | |||
uses: actions/checkout@v3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just updated these as older actions will stop working eventually (some nodejs thing that GitHub deprecated).
@@ -45,14 +47,30 @@ func IsForcePush(hook *HookInfo) (bool, error) { | |||
return base != hook.OldRev, nil | |||
} | |||
|
|||
func (r *Receiver) CheckAllowedBranch(hook *HookInfo) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this public so I could add a test. Otherwise, the code in Handle
requires a full blown setup with commits and repositories and so on. Not ideal, but hope it's alright.
receiver.go
Outdated
@@ -45,14 +47,30 @@ func IsForcePush(hook *HookInfo) (bool, error) { | |||
return base != hook.OldRev, nil | |||
} | |||
|
|||
func (r *Receiver) CheckAllowedBranch(hook *HookInfo) error { | |||
if r.MasterOnly { // for BC | |||
r.AllowedBranches = append(r.AllowedBranches, "refs/heads/master") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured comparing to the actual names, saved some parsing. But let me know if you'd like another API with straight up branch names like []string{"master","main","etc"}
instead.
@sosedoff Can you take a look some time? |
Yea will review this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far, see my comments and adjust accordingly.
This extends MasterOnly and makes it configurable. The idea is to set arbitrary branch names which are allowed to be pushed to and otherwise return an error. Resolves: sosedoff#33
- renamed AllowedBranches to AllowedRefs - use t.Run() in tests
@sosedoff this took me a bit longer than expected, can you have a look again? |
@sosedoff any interest in this? |
Probably, i haven't used the repo myself in quite a bit so getting up to speed will take some time |