|
|
@ -155,27 +155,29 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) ( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Simulate push event.
|
|
|
|
// Simulate push event.
|
|
|
|
pushCommits := &PushCommits{ |
|
|
|
|
|
|
|
Len: 1, |
|
|
|
|
|
|
|
Commits: []*PushCommit{CommitToPushCommit(commit)}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
oldCommitID := opts.LastCommitID |
|
|
|
oldCommitID := opts.LastCommitID |
|
|
|
if opts.NewBranch != opts.OldBranch { |
|
|
|
if opts.NewBranch != opts.OldBranch { |
|
|
|
oldCommitID = git.EmptySHA |
|
|
|
oldCommitID = git.EmptySHA |
|
|
|
} |
|
|
|
} |
|
|
|
if err := CommitRepoAction(CommitRepoActionOptions{ |
|
|
|
|
|
|
|
|
|
|
|
if err = repo.GetOwner(); err != nil { |
|
|
|
|
|
|
|
return fmt.Errorf("GetOwner: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
err = PushUpdate( |
|
|
|
|
|
|
|
opts.NewBranch, |
|
|
|
|
|
|
|
PushUpdateOptions{ |
|
|
|
|
|
|
|
PusherID: doer.ID, |
|
|
|
PusherName: doer.Name, |
|
|
|
PusherName: doer.Name, |
|
|
|
RepoOwnerID: repo.MustOwner().ID, |
|
|
|
RepoUserName: repo.Owner.Name, |
|
|
|
RepoName: repo.Name, |
|
|
|
RepoName: repo.Name, |
|
|
|
RefFullName: git.BranchPrefix + opts.NewBranch, |
|
|
|
RefFullName: git.BranchPrefix + opts.NewBranch, |
|
|
|
OldCommitID: oldCommitID, |
|
|
|
OldCommitID: oldCommitID, |
|
|
|
NewCommitID: commit.ID.String(), |
|
|
|
NewCommitID: commit.ID.String(), |
|
|
|
Commits: pushCommits, |
|
|
|
}, |
|
|
|
}); err != nil { |
|
|
|
) |
|
|
|
log.Error(4, "CommitRepoAction: %v", err) |
|
|
|
if err != nil { |
|
|
|
return nil |
|
|
|
return fmt.Errorf("PushUpdate: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -295,23 +297,29 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) ( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Simulate push event.
|
|
|
|
// Simulate push event.
|
|
|
|
pushCommits := &PushCommits{ |
|
|
|
oldCommitID := opts.LastCommitID |
|
|
|
Len: 1, |
|
|
|
if opts.NewBranch != opts.OldBranch { |
|
|
|
Commits: []*PushCommit{CommitToPushCommit(commit)}, |
|
|
|
oldCommitID = git.EmptySHA |
|
|
|
} |
|
|
|
} |
|
|
|
if err := CommitRepoAction(CommitRepoActionOptions{ |
|
|
|
|
|
|
|
|
|
|
|
if err = repo.GetOwner(); err != nil { |
|
|
|
|
|
|
|
return fmt.Errorf("GetOwner: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
err = PushUpdate( |
|
|
|
|
|
|
|
opts.NewBranch, |
|
|
|
|
|
|
|
PushUpdateOptions{ |
|
|
|
|
|
|
|
PusherID: doer.ID, |
|
|
|
PusherName: doer.Name, |
|
|
|
PusherName: doer.Name, |
|
|
|
RepoOwnerID: repo.MustOwner().ID, |
|
|
|
RepoUserName: repo.Owner.Name, |
|
|
|
RepoName: repo.Name, |
|
|
|
RepoName: repo.Name, |
|
|
|
RefFullName: git.BranchPrefix + opts.NewBranch, |
|
|
|
RefFullName: git.BranchPrefix + opts.NewBranch, |
|
|
|
OldCommitID: opts.LastCommitID, |
|
|
|
OldCommitID: oldCommitID, |
|
|
|
NewCommitID: commit.ID.String(), |
|
|
|
NewCommitID: commit.ID.String(), |
|
|
|
Commits: pushCommits, |
|
|
|
}, |
|
|
|
}); err != nil { |
|
|
|
) |
|
|
|
log.Error(4, "CommitRepoAction: %v", err) |
|
|
|
if err != nil { |
|
|
|
return nil |
|
|
|
return fmt.Errorf("PushUpdate: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -534,21 +542,28 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Simulate push event.
|
|
|
|
// Simulate push event.
|
|
|
|
pushCommits := &PushCommits{ |
|
|
|
oldCommitID := opts.LastCommitID |
|
|
|
Len: 1, |
|
|
|
if opts.NewBranch != opts.OldBranch { |
|
|
|
Commits: []*PushCommit{CommitToPushCommit(commit)}, |
|
|
|
oldCommitID = git.EmptySHA |
|
|
|
} |
|
|
|
} |
|
|
|
if err := CommitRepoAction(CommitRepoActionOptions{ |
|
|
|
|
|
|
|
|
|
|
|
if err = repo.GetOwner(); err != nil { |
|
|
|
|
|
|
|
return fmt.Errorf("GetOwner: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
err = PushUpdate( |
|
|
|
|
|
|
|
opts.NewBranch, |
|
|
|
|
|
|
|
PushUpdateOptions{ |
|
|
|
|
|
|
|
PusherID: doer.ID, |
|
|
|
PusherName: doer.Name, |
|
|
|
PusherName: doer.Name, |
|
|
|
RepoOwnerID: repo.MustOwner().ID, |
|
|
|
RepoUserName: repo.Owner.Name, |
|
|
|
RepoName: repo.Name, |
|
|
|
RepoName: repo.Name, |
|
|
|
RefFullName: git.BranchPrefix + opts.NewBranch, |
|
|
|
RefFullName: git.BranchPrefix + opts.NewBranch, |
|
|
|
OldCommitID: opts.LastCommitID, |
|
|
|
OldCommitID: oldCommitID, |
|
|
|
NewCommitID: commit.ID.String(), |
|
|
|
NewCommitID: commit.ID.String(), |
|
|
|
Commits: pushCommits, |
|
|
|
}, |
|
|
|
}); err != nil { |
|
|
|
) |
|
|
|
log.Error(4, "CommitRepoAction: %v", err) |
|
|
|
if err != nil { |
|
|
|
return nil |
|
|
|
return fmt.Errorf("PushUpdate: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return DeleteUploads(uploads...) |
|
|
|
return DeleteUploads(uploads...) |
|
|
|