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

Move PushUpdateOptions from models to repofiles #9124

Merged
merged 3 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions models/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ func ListToPushCommits(l *list.List) *PushCommits {
return &PushCommits{l.Len(), commits, "", make(map[string]string), make(map[string]*User)}
}

// PushUpdateOptions defines the push update options
type PushUpdateOptions struct {
PusherID int64
PusherName string
RepoUserName string
RepoName string
RefFullName string
OldCommitID string
NewCommitID string
}

// PushUpdateDeleteTag must be called for any push actions to delete tag
func PushUpdateDeleteTag(repo *Repository, tagName string) error {
rel, err := GetRelease(repo.ID, tagName)
Expand Down
13 changes: 12 additions & 1 deletion modules/repofiles/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,20 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
return file, nil
}

// PushUpdateOptions defines the push update options
type PushUpdateOptions struct {
PusherID int64
PusherName string
RepoUserName string
RepoName string
RefFullName string
OldCommitID string
NewCommitID string
}

// PushUpdate must be called for any push actions in order to
// generates necessary push action history feeds and other operations
func PushUpdate(repo *models.Repository, branch string, opts models.PushUpdateOptions) error {
func PushUpdate(repo *models.Repository, branch string, opts PushUpdateOptions) error {
isNewRef := opts.OldCommitID == git.EmptySHA
isDelRef := opts.NewCommitID == git.EmptySHA
if isNewRef && isDelRef {
Expand Down
2 changes: 1 addition & 1 deletion routers/private/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func HookPostReceive(ctx *macaron.Context) {
})
return
}
if err := repofiles.PushUpdate(repo, branch, models.PushUpdateOptions{
if err := repofiles.PushUpdate(repo, branch, repofiles.PushUpdateOptions{
RefFullName: refFullName,
OldCommitID: oldCommitID,
NewCommitID: newCommitID,
Expand Down
2 changes: 1 addition & 1 deletion routers/private/push_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

// PushUpdate update public key updates
func PushUpdate(ctx *macaron.Context) {
var opt models.PushUpdateOptions
var opt repofiles.PushUpdateOptions
if err := json.NewDecoder(ctx.Req.Request.Body).Decode(&opt); err != nil {
ctx.JSON(500, map[string]interface{}{
"err": err.Error(),
Expand Down
2 changes: 1 addition & 1 deletion routers/repo/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func deleteBranch(ctx *context.Context, branchName string) error {
if err := repofiles.PushUpdate(
ctx.Repo.Repository,
branchName,
models.PushUpdateOptions{
repofiles.PushUpdateOptions{
RefFullName: git.BranchPrefix + branchName,
OldCommitID: commit.ID.String(),
NewCommitID: git.EmptySHA,
Expand Down