Skip to content

Commit cb24cbc

Browse files
manuelluisGitea6543
authored
Fix branch/tag notifications in mirror sync (#13855) (#13862)
Co-authored-by: Gitea <[email protected]> Co-authored-by: 6543 <[email protected]>
1 parent 584d01c commit cb24cbc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

services/mirror/mirror.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ func parseRemoteUpdateOutput(output string) []*mirrorSyncResult {
149149

150150
switch {
151151
case strings.HasPrefix(lines[i], " * "): // New reference
152+
if strings.HasPrefix(lines[i], " * [new tag]") {
153+
refName = git.TagPrefix + refName
154+
} else if strings.HasPrefix(lines[i], " * [new branch]") {
155+
refName = git.BranchPrefix + refName
156+
}
152157
results = append(results, &mirrorSyncResult{
153158
refName: refName,
154159
oldCommitID: gitShortEmptySha,
@@ -434,6 +439,17 @@ func syncMirror(repoID string) {
434439

435440
// Create reference
436441
if result.oldCommitID == gitShortEmptySha {
442+
if tp == git.TagPrefix {
443+
tp = "tag"
444+
} else if tp == git.BranchPrefix {
445+
tp = "branch"
446+
}
447+
commitID, err := gitRepo.GetRefCommitID(result.refName)
448+
if err != nil {
449+
log.Error("gitRepo.GetRefCommitID [repo_id: %s, ref_name: %s]: %v", m.RepoID, result.refName, err)
450+
continue
451+
}
452+
notification.NotifySyncPushCommits(m.Repo.MustOwner(), m.Repo, result.refName, git.EmptySHA, commitID, repo_module.NewPushCommits())
437453
notification.NotifySyncCreateRef(m.Repo.MustOwner(), m.Repo, tp, result.refName)
438454
continue
439455
}

0 commit comments

Comments
 (0)