@@ -155,27 +155,29 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
155
155
}
156
156
157
157
// Simulate push event.
158
- pushCommits := & PushCommits {
159
- Len : 1 ,
160
- Commits : []* PushCommit {CommitToPushCommit (commit )},
161
- }
162
158
oldCommitID := opts .LastCommitID
163
159
if opts .NewBranch != opts .OldBranch {
164
160
oldCommitID = git .EmptySHA
165
161
}
166
- if err := CommitRepoAction (CommitRepoActionOptions {
167
- PusherName : doer .Name ,
168
- RepoOwnerID : repo .MustOwner ().ID ,
169
- RepoName : repo .Name ,
170
- RefFullName : git .BranchPrefix + opts .NewBranch ,
171
- OldCommitID : oldCommitID ,
172
- NewCommitID : commit .ID .String (),
173
- Commits : pushCommits ,
174
- }); err != nil {
175
- log .Error (4 , "CommitRepoAction: %v" , err )
176
- return nil
177
- }
178
162
163
+ if err = repo .GetOwner (); err != nil {
164
+ return fmt .Errorf ("GetOwner: %v" , err )
165
+ }
166
+ err = PushUpdate (
167
+ opts .NewBranch ,
168
+ PushUpdateOptions {
169
+ PusherID : doer .ID ,
170
+ PusherName : doer .Name ,
171
+ RepoUserName : repo .Owner .Name ,
172
+ RepoName : repo .Name ,
173
+ RefFullName : git .BranchPrefix + opts .NewBranch ,
174
+ OldCommitID : oldCommitID ,
175
+ NewCommitID : commit .ID .String (),
176
+ },
177
+ )
178
+ if err != nil {
179
+ return fmt .Errorf ("PushUpdate: %v" , err )
180
+ }
179
181
return nil
180
182
}
181
183
@@ -295,23 +297,29 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
295
297
}
296
298
297
299
// Simulate push event.
298
- pushCommits := & PushCommits {
299
- Len : 1 ,
300
- Commits : []* PushCommit {CommitToPushCommit (commit )},
301
- }
302
- if err := CommitRepoAction (CommitRepoActionOptions {
303
- PusherName : doer .Name ,
304
- RepoOwnerID : repo .MustOwner ().ID ,
305
- RepoName : repo .Name ,
306
- RefFullName : git .BranchPrefix + opts .NewBranch ,
307
- OldCommitID : opts .LastCommitID ,
308
- NewCommitID : commit .ID .String (),
309
- Commits : pushCommits ,
310
- }); err != nil {
311
- log .Error (4 , "CommitRepoAction: %v" , err )
312
- return nil
300
+ oldCommitID := opts .LastCommitID
301
+ if opts .NewBranch != opts .OldBranch {
302
+ oldCommitID = git .EmptySHA
313
303
}
314
304
305
+ if err = repo .GetOwner (); err != nil {
306
+ return fmt .Errorf ("GetOwner: %v" , err )
307
+ }
308
+ err = PushUpdate (
309
+ opts .NewBranch ,
310
+ PushUpdateOptions {
311
+ PusherID : doer .ID ,
312
+ PusherName : doer .Name ,
313
+ RepoUserName : repo .Owner .Name ,
314
+ RepoName : repo .Name ,
315
+ RefFullName : git .BranchPrefix + opts .NewBranch ,
316
+ OldCommitID : oldCommitID ,
317
+ NewCommitID : commit .ID .String (),
318
+ },
319
+ )
320
+ if err != nil {
321
+ return fmt .Errorf ("PushUpdate: %v" , err )
322
+ }
315
323
return nil
316
324
}
317
325
@@ -534,21 +542,28 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
534
542
}
535
543
536
544
// Simulate push event.
537
- pushCommits := & PushCommits {
538
- Len : 1 ,
539
- Commits : []* PushCommit {CommitToPushCommit (commit )},
540
- }
541
- if err := CommitRepoAction (CommitRepoActionOptions {
542
- PusherName : doer .Name ,
543
- RepoOwnerID : repo .MustOwner ().ID ,
544
- RepoName : repo .Name ,
545
- RefFullName : git .BranchPrefix + opts .NewBranch ,
546
- OldCommitID : opts .LastCommitID ,
547
- NewCommitID : commit .ID .String (),
548
- Commits : pushCommits ,
549
- }); err != nil {
550
- log .Error (4 , "CommitRepoAction: %v" , err )
551
- return nil
545
+ oldCommitID := opts .LastCommitID
546
+ if opts .NewBranch != opts .OldBranch {
547
+ oldCommitID = git .EmptySHA
548
+ }
549
+
550
+ if err = repo .GetOwner (); err != nil {
551
+ return fmt .Errorf ("GetOwner: %v" , err )
552
+ }
553
+ err = PushUpdate (
554
+ opts .NewBranch ,
555
+ PushUpdateOptions {
556
+ PusherID : doer .ID ,
557
+ PusherName : doer .Name ,
558
+ RepoUserName : repo .Owner .Name ,
559
+ RepoName : repo .Name ,
560
+ RefFullName : git .BranchPrefix + opts .NewBranch ,
561
+ OldCommitID : oldCommitID ,
562
+ NewCommitID : commit .ID .String (),
563
+ },
564
+ )
565
+ if err != nil {
566
+ return fmt .Errorf ("PushUpdate: %v" , err )
552
567
}
553
568
554
569
return DeleteUploads (uploads ... )
0 commit comments