* Handle broken references in mirror sync
If there are broken references during a mirror attempt to fix using `git remote prune`.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
// sanitize the output, since it may contain the remote address, which may
// contain a password
sanitizer:=util.NewURLSanitizer(remoteAddr,true)
stderrMessage:=sanitizer.Replace(stderr)
stdoutMessage:=sanitizer.Replace(stdout)
log.Error("Failed to update mirror repository %v:\nStdout: %s\nStderr: %s\nErr: %v",m.Repo,stdoutMessage,stderrMessage,err)
// Now check if the error is a resolve reference due to broken reference
ifstrings.Contains(stderr,"unable to resolve reference")&&strings.Contains(stderr,"reference broken"){
log.Warn("Failed to update mirror repository %-v due to broken references:\nStdout: %s\nStderr: %s\nErr: %v\nAttempting Prune",m.Repo,stdoutMessage,stderrMessage,err)
// sanitize the output, since it may contain the remote address, which may
// contain a password
sanitizer:=util.NewURLSanitizer(remoteAddr,true)
stderrMessage:=sanitizer.Replace(stderr)
stdoutMessage:=sanitizer.Replace(stdout)
log.Error("Failed to update mirror repository wiki %v:\nStdout: %s\nStderr: %s\nErr: %v",m.Repo,stdoutMessage,stderrMessage,err)
// Now check if the error is a resolve reference due to broken reference
ifstrings.Contains(stderrMessage,"unable to resolve reference")&&strings.Contains(stderrMessage,"reference broken"){
log.Warn("Failed to update mirror wiki repository %-v due to broken references:\nStdout: %s\nStderr: %s\nErr: %v\nAttempting Prune",m.Repo,stdoutMessage,stderrMessage,err)