diff --git a/app/models/repository.rb b/app/models/repository.rb index f717d24861536da5eccc0f078558dcb878ae166b..73c4899cb9b593bfbb7d62da2ac4dcc1c4422031 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -259,17 +259,7 @@ class Repository return if kept_around?(sha) # This will still fail if the file is corrupted (e.g. 0 bytes) - begin - raw_repository.write_ref(keep_around_ref_name(sha), sha, shell: false) - rescue Gitlab::Git::CommandError => ex - if ex.message.start_with?("ReferenceError: ") - Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}" - elsif ex.message.start_with?("OSError: ") - raise unless ex.message =~ /Failed to create locked file/ && ex.message =~ /File exists/ - - Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}" - end - end + raw_repository.write_ref(keep_around_ref_name(sha), sha, shell: false) end def kept_around?(sha) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index e36ab2e32f677f9a225893dabf0c4e50da6eb2bb..27037af55c6b4c398d13cbcdf531cf4805b80e1b 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -1395,9 +1395,11 @@ module Gitlab def rugged_write_ref(ref_path, ref) rugged.references.create(ref_path, ref, force: true) rescue Rugged::ReferenceError => ex - raise CommandError, "ReferenceError: #{ex}" + Rails.logger.error "Unable to create #{ref_path} reference for repository #{path}: #{ex}" rescue Rugged::OSError => ex - raise CommandError, "OSError: #{ex}" + raise unless ex.message =~ /Failed to create locked file/ && ex.message =~ /File exists/ + + Rails.logger.error "Unable to create #{ref_path} reference for repository #{path}: #{ex}" end def fresh_worktree?(path)