@ -201,7 +201,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
remoteAddr , remoteErr := git . GetRemoteAddress ( ctx , repoPath , m . GetRemoteName ( ) )
remoteAddr , remoteErr := git . GetRemoteAddress ( ctx , repoPath , m . GetRemoteName ( ) )
if remoteErr != nil {
if remoteErr != nil {
log . Error ( "GetRemoteAddress Error %v" , remoteErr )
log . Error ( "SyncMirrors [repo: %-v]: GetRemoteAddress Error %v" , m . Repo , remoteErr )
}
}
stdoutBuilder := strings . Builder { }
stdoutBuilder := strings . Builder { }
@ -225,7 +225,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
// Now check if the error is a resolve reference due to broken reference
// Now check if the error is a resolve reference due to broken reference
if strings . Contains ( stderr , "unable to resolve reference" ) && strings . Contains ( stderr , "reference broken" ) {
if strings . 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 )
log . Warn ( "SyncMirrors [repo: %-v]: failed to update mirror repository due to broken references:\nStdout: %s\nStderr: %s\nErr: %v\nAttempting Prune" , m . Repo , stdoutMessage , stderrMessage , err )
err = nil
err = nil
// Attempt prune
// Attempt prune
@ -255,7 +255,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
// If there is still an error (or there always was an error)
// If there is still an error (or there always was an error)
if err != nil {
if err != nil {
log . Error ( "Failed to update mirror repository %-v :\nStdout: %s\nStderr: %s\nErr: %v" , m . Repo , stdoutMessage , stderrMessage , err )
log . Error ( "SyncMirrors [repo: %-v]: failed to update mirror repository :\nStdout: %s\nStderr: %s\nErr: %v" , m . Repo , stdoutMessage , stderrMessage , err )
desc := fmt . Sprintf ( "Failed to update mirror repository '%s': %s" , repoPath , stderrMessage )
desc := fmt . Sprintf ( "Failed to update mirror repository '%s': %s" , repoPath , stderrMessage )
if err = admin_model . CreateRepositoryNotice ( desc ) ; err != nil {
if err = admin_model . CreateRepositoryNotice ( desc ) ; err != nil {
log . Error ( "CreateRepositoryNotice: %v" , err )
log . Error ( "CreateRepositoryNotice: %v" , err )
@ -267,13 +267,13 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
gitRepo , err := git . OpenRepositoryCtx ( ctx , repoPath )
gitRepo , err := git . OpenRepositoryCtx ( ctx , repoPath )
if err != nil {
if err != nil {
log . Error ( "OpenRepository: %v" , err )
log . Error ( "SyncMirrors [repo: %-v]: failed to OpenRepository: %v" , m . Repo , err )
return nil , false
return nil , false
}
}
log . Trace ( "SyncMirrors [repo: %-v]: syncing releases with tags..." , m . Repo )
log . Trace ( "SyncMirrors [repo: %-v]: syncing releases with tags..." , m . Repo )
if err = repo_module . SyncReleasesWithTags ( m . Repo , gitRepo ) ; err != nil {
if err = repo_module . SyncReleasesWithTags ( m . Repo , gitRepo ) ; err != nil {
log . Error ( "Failed to synchronize tags to releases for repository: %v" , err )
log . Error ( "SyncMirrors [repo: %-v]: failed to synchronize tags to releases: %v" , m . Repo , err )
}
}
if m . LFS && setting . LFS . StartServer {
if m . LFS && setting . LFS . StartServer {
@ -281,14 +281,14 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
endpoint := lfs . DetermineEndpoint ( remoteAddr . String ( ) , m . LFSEndpoint )
endpoint := lfs . DetermineEndpoint ( remoteAddr . String ( ) , m . LFSEndpoint )
lfsClient := lfs . NewClient ( endpoint , nil )
lfsClient := lfs . NewClient ( endpoint , nil )
if err = repo_module . StoreMissingLfsObjectsInRepository ( ctx , m . Repo , gitRepo , lfsClient ) ; err != nil {
if err = repo_module . StoreMissingLfsObjectsInRepository ( ctx , m . Repo , gitRepo , lfsClient ) ; err != nil {
log . Error ( "F ailed to synchronize LFS objects for repository: %v" , err )
log . Error ( "SyncMirrors [repo: %-v]: f ailed to synchronize LFS objects for repository: %v" , m . Repo , err )
}
}
}
}
gitRepo . Close ( )
gitRepo . Close ( )
log . Trace ( "SyncMirrors [repo: %-v]: updating size of repository" , m . Repo )
log . Trace ( "SyncMirrors [repo: %-v]: updating size of repository" , m . Repo )
if err := models . UpdateRepoSize ( db . DefaultContext , m . Repo ) ; err != nil {
if err := models . UpdateRepoSize ( db . DefaultContext , m . Repo ) ; err != nil {
log . Error ( "F ailed to update size for mirror repository: %v" , err )
log . Error ( "SyncMirrors [repo: %-v]: f ailed to update size for mirror repository: %v" , m . Repo , err )
}
}
if m . Repo . HasWiki ( ) {
if m . Repo . HasWiki ( ) {
@ -311,7 +311,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
remoteAddr , remoteErr := git . GetRemoteAddress ( ctx , wikiPath , m . GetRemoteName ( ) )
remoteAddr , remoteErr := git . GetRemoteAddress ( ctx , wikiPath , m . GetRemoteName ( ) )
if remoteErr != nil {
if remoteErr != nil {
log . Error ( "GetRemoteAddress Error %v" , remoteErr )
log . Error ( "SyncMirrors [repo: %-v Wiki]: unable to get GetRemoteAddress Error %v" , m . Repo , remoteErr )
}
}
// sanitize the output, since it may contain the remote address, which may
// sanitize the output, since it may contain the remote address, which may
@ -322,7 +322,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
// Now check if the error is a resolve reference due to broken reference
// Now check if the error is a resolve reference due to broken reference
if strings . Contains ( stderrMessage , "unable to resolve reference" ) && strings . Contains ( stderrMessage , "reference broken" ) {
if strings . 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 )
log . Warn ( "SyncMirrors [repo: %-v Wiki]: failed to update mirror wiki repository due to broken references:\nStdout: %s\nStderr: %s\nErr: %v\nAttempting Prune" , m . Repo , stdoutMessage , stderrMessage , err )
err = nil
err = nil
// Attempt prune
// Attempt prune
@ -350,7 +350,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
// If there is still an error (or there always was an error)
// If there is still an error (or there always was an error)
if err != nil {
if err != nil {
log . Error ( "Failed to update mirror repository wiki %-v :\nStdout: %s\nStderr: %s\nErr: %v" , m . Repo , stdoutMessage , stderrMessage , err )
log . Error ( "SyncMirrors [repo: %-v Wiki]: failed to update mirror repository wiki :\nStdout: %s\nStderr: %s\nErr: %v" , m . Repo , stdoutMessage , stderrMessage , err )
desc := fmt . Sprintf ( "Failed to update mirror repository wiki '%s': %s" , wikiPath , stderrMessage )
desc := fmt . Sprintf ( "Failed to update mirror repository wiki '%s': %s" , wikiPath , stderrMessage )
if err = admin_model . CreateRepositoryNotice ( desc ) ; err != nil {
if err = admin_model . CreateRepositoryNotice ( desc ) ; err != nil {
log . Error ( "CreateRepositoryNotice: %v" , err )
log . Error ( "CreateRepositoryNotice: %v" , err )
@ -364,7 +364,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
log . Trace ( "SyncMirrors [repo: %-v]: invalidating mirror branch caches..." , m . Repo )
log . Trace ( "SyncMirrors [repo: %-v]: invalidating mirror branch caches..." , m . Repo )
branches , _ , err := git . GetBranchesByPath ( ctx , m . Repo . RepoPath ( ) , 0 , 0 )
branches , _ , err := git . GetBranchesByPath ( ctx , m . Repo . RepoPath ( ) , 0 , 0 )
if err != nil {
if err != nil {
log . Error ( "GetBranches: %v" , err )
log . Error ( "SyncMirrors [repo: %-v]: failed to GetBranches: %v" , m . Repo , err )
return nil , false
return nil , false
}
}
@ -385,12 +385,12 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
return
return
}
}
// There was a panic whilst syncMirrors...
// There was a panic whilst syncMirrors...
log . Error ( "PANIC whilst syncMirrors[ %d] Panic: %v\nStacktrace: %s" , repoID , err , log . Stack ( 2 ) )
log . Error ( "PANIC whilst SyncMirrors[repo_id: %d] Panic: %v\nStacktrace: %s" , repoID , err , log . Stack ( 2 ) )
} ( )
} ( )
m , err := repo_model . GetMirrorByRepoID ( repoID )
m , err := repo_model . GetMirrorByRepoID ( repoID )
if err != nil {
if err != nil {
log . Error ( "GetMirrorByRepoID [%d] : %v" , repoID , err )
log . Error ( "SyncMirrors [repo_id: %v]: unable to GetMirrorByRepoID: %v" , repoID , err )
return false
return false
}
}
@ -406,7 +406,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
log . Trace ( "SyncMirrors [repo: %-v]: Scheduling next update" , m . Repo )
log . Trace ( "SyncMirrors [repo: %-v]: Scheduling next update" , m . Repo )
m . ScheduleNextUpdate ( )
m . ScheduleNextUpdate ( )
if err = repo_model . UpdateMirror ( m ) ; err != nil {
if err = repo_model . UpdateMirror ( m ) ; err != nil {
log . Error ( "UpdateMirror [%d] : %v" , m . RepoID , err )
log . Error ( "SyncMirrors [repo: %-v]: failed to UpdateMirror with next update date : %v" , m . Repo , err )
return false
return false
}
}
@ -417,7 +417,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
log . Trace ( "SyncMirrors [repo: %-v]: %d branches updated" , m . Repo , len ( results ) )
log . Trace ( "SyncMirrors [repo: %-v]: %d branches updated" , m . Repo , len ( results ) )
gitRepo , err = git . OpenRepositoryCtx ( ctx , m . Repo . RepoPath ( ) )
gitRepo , err = git . OpenRepositoryCtx ( ctx , m . Repo . RepoPath ( ) )
if err != nil {
if err != nil {
log . Error ( "OpenRepository [%d] : %v" , m . RepoID , err )
log . Error ( "SyncMirrors [repo: %-v]: unable to OpenRepository: %v" , m . Repo , err )
return false
return false
}
}
defer gitRepo . Close ( )
defer gitRepo . Close ( )
@ -444,7 +444,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
}
}
commitID , err := gitRepo . GetRefCommitID ( result . refName )
commitID , err := gitRepo . GetRefCommitID ( result . refName )
if err != nil {
if err != nil {
log . Error ( "gitRepo.GetRefCommitID [repo_id: %d, ref_name: %s]: %v" , m . RepoID , result . refName , err )
log . Error ( "SyncMirrors [repo: %-v]: unable to GetRefCommitID [ ref_name: %s]: %v" , m . Repo , result . refName , err )
continue
continue
}
}
notification . NotifySyncPushCommits ( m . Repo . MustOwner ( ) , m . Repo , & repo_module . PushUpdateOptions {
notification . NotifySyncPushCommits ( m . Repo . MustOwner ( ) , m . Repo , & repo_module . PushUpdateOptions {
@ -465,17 +465,17 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
// Push commits
// Push commits
oldCommitID , err := git . GetFullCommitID ( gitRepo . Ctx , gitRepo . Path , result . oldCommitID )
oldCommitID , err := git . GetFullCommitID ( gitRepo . Ctx , gitRepo . Path , result . oldCommitID )
if err != nil {
if err != nil {
log . Error ( "GetFullCommitID [%d ]: %v" , m . RepoID , err )
log . Error ( "SyncMirrors [repo: %-v]: unable to get GetFullCommitID[%s ]: %v" , m . Repo , result . oldCommit ID, err )
continue
continue
}
}
newCommitID , err := git . GetFullCommitID ( gitRepo . Ctx , gitRepo . Path , result . newCommitID )
newCommitID , err := git . GetFullCommitID ( gitRepo . Ctx , gitRepo . Path , result . newCommitID )
if err != nil {
if err != nil {
log . Error ( "GetFullCommitID [%d ]: %v" , m . RepoID , err )
log . Error ( "SyncMirrors [repo: %-v]: unable to get GetFullCommitID [%s ]: %v" , m . Repo , result . newCommit ID, err )
continue
continue
}
}
commits , err := gitRepo . CommitsBetweenIDs ( newCommitID , oldCommitID )
commits , err := gitRepo . CommitsBetweenIDs ( newCommitID , oldCommitID )
if err != nil {
if err != nil {
log . Error ( "CommitsBetweenIDs [repo_id: %d, new_commit_id: %s, old_commit_id: %s]: %v" , m . RepoID , newCommitID , oldCommitID , err )
log . Error ( "SyncMirrors [repo: %-v]: unable to get CommitsBetweenIDs [new_commit_id: %s, old_commit_id: %s]: %v" , m . Repo , newCommitID , oldCommitID , err )
continue
continue
}
}
@ -497,12 +497,12 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
// Get latest commit date and update to current repository updated time
// Get latest commit date and update to current repository updated time
commitDate , err := git . GetLatestCommitTime ( ctx , m . Repo . RepoPath ( ) )
commitDate , err := git . GetLatestCommitTime ( ctx , m . Repo . RepoPath ( ) )
if err != nil {
if err != nil {
log . Error ( "GetLatestCommitDate [%d] : %v" , m . RepoID , err )
log . Error ( "SyncMirrors [repo: %-v]: unable to GetLatestCommitDate: %v" , m . Repo , err )
return false
return false
}
}
if err = repo_model . UpdateRepositoryUpdatedTime ( m . RepoID , commitDate ) ; err != nil {
if err = repo_model . UpdateRepositoryUpdatedTime ( m . RepoID , commitDate ) ; err != nil {
log . Error ( "Update repository 'updated_unix' [%d] : %v" , m . RepoID , err )
log . Error ( "SyncMirrors [repo: %-v]: unable to update repository 'updated_unix' : %v" , m . Repo , err )
return false
return false
}
}