summaryrefslogtreecommitdiffstats
path: root/services/mirror
diff options
context:
space:
mode:
authormanuelluis <manuel.luis@gmail.com>2020-12-05 16:13:11 +0100
committerGitHub <noreply@github.com>2020-12-05 23:13:11 +0800
commit8561f266955650822913f6f8ac617265d16826c3 (patch)
tree3c048a55a7eb2446c7c8d0655641f6446aa43f8a /services/mirror
parentd0d59e3730600db21d75d0848d551cb098262b88 (diff)
downloadgitea-8561f266955650822913f6f8ac617265d16826c3.tar.gz
gitea-8561f266955650822913f6f8ac617265d16826c3.zip
Fix branch/tag notifications in mirror sync (#13855)
* Fix branch/tag notifications in mirror sync * Fix gofmt Co-authored-by: Gitea <gitea@fake.local> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'services/mirror')
-rw-r--r--services/mirror/mirror.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go
index cfef55f2a7..7c3d0d2239 100644
--- a/services/mirror/mirror.go
+++ b/services/mirror/mirror.go
@@ -149,6 +149,11 @@ func parseRemoteUpdateOutput(output string) []*mirrorSyncResult {
switch {
case strings.HasPrefix(lines[i], " * "): // New reference
+ if strings.HasPrefix(lines[i], " * [new tag]") {
+ refName = git.TagPrefix + refName
+ } else if strings.HasPrefix(lines[i], " * [new branch]") {
+ refName = git.BranchPrefix + refName
+ }
results = append(results, &mirrorSyncResult{
refName: refName,
oldCommitID: gitShortEmptySha,
@@ -438,6 +443,21 @@ func syncMirror(repoID string) {
// Create reference
if result.oldCommitID == gitShortEmptySha {
+ if tp == git.TagPrefix {
+ tp = "tag"
+ } else if tp == git.BranchPrefix {
+ tp = "branch"
+ }
+ commitID, err := gitRepo.GetRefCommitID(result.refName)
+ if err != nil {
+ log.Error("gitRepo.GetRefCommitID [repo_id: %s, ref_name: %s]: %v", m.RepoID, result.refName, err)
+ continue
+ }
+ notification.NotifySyncPushCommits(m.Repo.MustOwner(), m.Repo, &repo_module.PushUpdateOptions{
+ RefFullName: result.refName,
+ OldCommitID: git.EmptySHA,
+ NewCommitID: commitID,
+ }, repo_module.NewPushCommits())
notification.NotifySyncCreateRef(m.Repo.MustOwner(), m.Repo, tp, result.refName)
continue
}