diff options
Diffstat (limited to 'services/mirror/mirror.go')
-rw-r--r-- | services/mirror/mirror.go | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go index 8c8131b5c2..d35a205d00 100644 --- a/services/mirror/mirror.go +++ b/services/mirror/mirror.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/sync" @@ -336,19 +337,17 @@ func syncMirror(repoID string) { continue } + tp, _ := git.SplitRefName(result.refName) + // Create reference if result.oldCommitID == gitShortEmptySha { - if err = SyncCreateAction(m.Repo, result.refName); err != nil { - log.Error("SyncCreateAction [repo_id: %d]: %v", m.RepoID, err) - } + notification.NotifySyncCreateRef(m.Repo.MustOwner(), m.Repo, tp, result.refName) continue } // Delete reference if result.newCommitID == gitShortEmptySha { - if err = SyncDeleteAction(m.Repo, result.refName); err != nil { - log.Error("SyncDeleteAction [repo_id: %d]: %v", m.RepoID, err) - } + notification.NotifySyncDeleteRef(m.Repo.MustOwner(), m.Repo, tp, result.refName) continue } @@ -368,15 +367,15 @@ func syncMirror(repoID string) { log.Error("CommitsBetweenIDs [repo_id: %d, new_commit_id: %s, old_commit_id: %s]: %v", m.RepoID, newCommitID, oldCommitID, err) continue } - if err = SyncPushAction(m.Repo, SyncPushActionOptions{ - RefName: result.refName, - OldCommitID: oldCommitID, - NewCommitID: newCommitID, - Commits: models.ListToPushCommits(commits), - }); err != nil { - log.Error("SyncPushAction [repo_id: %d]: %v", m.RepoID, err) - continue + + theCommits := models.ListToPushCommits(commits) + if len(theCommits.Commits) > setting.UI.FeedMaxCommitNum { + theCommits.Commits = theCommits.Commits[:setting.UI.FeedMaxCommitNum] } + + theCommits.CompareURL = m.Repo.ComposeCompareURL(oldCommitID, newCommitID) + + notification.NotifySyncPushCommits(m.Repo.MustOwner(), m.Repo, result.refName, oldCommitID, newCommitID, models.ListToPushCommits(commits)) } // Get latest commit date and update to current repository updated time |