Skip to content

Commit 4e7ca94

Browse files
author
Gusted
authored
Use *PushUpdateOptions as receiver (#17724)
1 parent c97d66d commit 4e7ca94

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

modules/repository/push.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,67 +23,67 @@ type PushUpdateOptions struct {
2323
}
2424

2525
// IsNewRef return true if it's a first-time push to a branch, tag or etc.
26-
func (opts PushUpdateOptions) IsNewRef() bool {
26+
func (opts *PushUpdateOptions) IsNewRef() bool {
2727
return opts.OldCommitID == git.EmptySHA
2828
}
2929

3030
// IsDelRef return true if it's a deletion to a branch or tag
31-
func (opts PushUpdateOptions) IsDelRef() bool {
31+
func (opts *PushUpdateOptions) IsDelRef() bool {
3232
return opts.NewCommitID == git.EmptySHA
3333
}
3434

3535
// IsUpdateRef return true if it's an update operation
36-
func (opts PushUpdateOptions) IsUpdateRef() bool {
36+
func (opts *PushUpdateOptions) IsUpdateRef() bool {
3737
return !opts.IsNewRef() && !opts.IsDelRef()
3838
}
3939

4040
// IsTag return true if it's an operation to a tag
41-
func (opts PushUpdateOptions) IsTag() bool {
41+
func (opts *PushUpdateOptions) IsTag() bool {
4242
return strings.HasPrefix(opts.RefFullName, git.TagPrefix)
4343
}
4444

4545
// IsNewTag return true if it's a creation to a tag
46-
func (opts PushUpdateOptions) IsNewTag() bool {
46+
func (opts *PushUpdateOptions) IsNewTag() bool {
4747
return opts.IsTag() && opts.IsNewRef()
4848
}
4949

5050
// IsDelTag return true if it's a deletion to a tag
51-
func (opts PushUpdateOptions) IsDelTag() bool {
51+
func (opts *PushUpdateOptions) IsDelTag() bool {
5252
return opts.IsTag() && opts.IsDelRef()
5353
}
5454

5555
// IsBranch return true if it's a push to branch
56-
func (opts PushUpdateOptions) IsBranch() bool {
56+
func (opts *PushUpdateOptions) IsBranch() bool {
5757
return strings.HasPrefix(opts.RefFullName, git.BranchPrefix)
5858
}
5959

6060
// IsNewBranch return true if it's the first-time push to a branch
61-
func (opts PushUpdateOptions) IsNewBranch() bool {
61+
func (opts *PushUpdateOptions) IsNewBranch() bool {
6262
return opts.IsBranch() && opts.IsNewRef()
6363
}
6464

6565
// IsUpdateBranch return true if it's not the first push to a branch
66-
func (opts PushUpdateOptions) IsUpdateBranch() bool {
66+
func (opts *PushUpdateOptions) IsUpdateBranch() bool {
6767
return opts.IsBranch() && opts.IsUpdateRef()
6868
}
6969

7070
// IsDelBranch return true if it's a deletion to a branch
71-
func (opts PushUpdateOptions) IsDelBranch() bool {
71+
func (opts *PushUpdateOptions) IsDelBranch() bool {
7272
return opts.IsBranch() && opts.IsDelRef()
7373
}
7474

7575
// TagName returns simple tag name if it's an operation to a tag
76-
func (opts PushUpdateOptions) TagName() string {
76+
func (opts *PushUpdateOptions) TagName() string {
7777
return opts.RefFullName[len(git.TagPrefix):]
7878
}
7979

8080
// BranchName returns simple branch name if it's an operation to branch
81-
func (opts PushUpdateOptions) BranchName() string {
81+
func (opts *PushUpdateOptions) BranchName() string {
8282
return opts.RefFullName[len(git.BranchPrefix):]
8383
}
8484

8585
// RefName returns simple name for ref
86-
func (opts PushUpdateOptions) RefName() string {
86+
func (opts *PushUpdateOptions) RefName() string {
8787
if strings.HasPrefix(opts.RefFullName, git.TagPrefix) {
8888
return opts.RefFullName[len(git.TagPrefix):]
8989
} else if strings.HasPrefix(opts.RefFullName, git.BranchPrefix) {
@@ -93,7 +93,7 @@ func (opts PushUpdateOptions) RefName() string {
9393
}
9494

9595
// RepoFullName returns repo full name
96-
func (opts PushUpdateOptions) RepoFullName() string {
96+
func (opts *PushUpdateOptions) RepoFullName() string {
9797
return opts.RepoUserName + "/" + opts.RepoName
9898
}
9999

routers/private/hook_post_receive.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
5757
wasEmpty = repo.IsEmpty
5858
}
5959

60-
option := repo_module.PushUpdateOptions{
60+
option := &repo_module.PushUpdateOptions{
6161
RefFullName: refFullName,
6262
OldCommitID: opts.OldCommitIDs[i],
6363
NewCommitID: opts.NewCommitIDs[i],
@@ -66,11 +66,11 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
6666
RepoUserName: ownerName,
6767
RepoName: repoName,
6868
}
69-
updates = append(updates, &option)
69+
updates = append(updates, option)
7070
if repo.IsEmpty && option.IsBranch() && (option.BranchName() == "master" || option.BranchName() == "main") {
7171
// put the master/main branch first
7272
copy(updates[1:], updates)
73-
updates[0] = &option
73+
updates[0] = option
7474
}
7575
}
7676
}

0 commit comments

Comments
 (0)