Skip to content

Commit 5cbb665

Browse files
author
kselvraj
committed
OTWO-5721: Cleanup git lock file before checkout
1 parent c0cc4f0 commit 5cbb665

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/ohloh_scm/git/scm.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module OhlohScm
44
module Git
5-
class Scm < OhlohScm::Scm
5+
class Scm < OhlohScm::Scm # rubocop:disable Metrics/ClassLength
66
def initialize(core:, url:, branch_name:, username:, password:)
77
super
88
@branch_name = branch_name || 'master'
@@ -54,14 +54,18 @@ def clone_and_create_tracking_branch(remote_scm)
5454
# We need very high reliability and this sequence gets the job done every time.
5555
def clean_and_checkout_branch
5656
return unless status.scm_dir_exist?
57-
58-
run "cd '#{url}' && git clean -f -d -x"
5957
return unless status.branch?(branch_name)
6058

59+
run "cd '#{url}' && git clean -f -d -x"
60+
clean_git_lock_file
6161
run "cd '#{url}' && git reset --hard HEAD"
6262
run "cd '#{url}' && git checkout #{branch_name} --"
6363
end
6464

65+
def clean_git_lock_file
66+
run "rm #{url}/.git/index.lock" if File.exist?("#{url}/.git/index.lock")
67+
end
68+
6569
def create_tracking_branch(branch_name)
6670
return if branch_name.to_s.empty?
6771
return if activity.branches.include?(branch_name)

lib/ohloh_scm/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module OhlohScm
44
module Version
5-
STRING = '3.0.5'
5+
STRING = '3.0.6'
66
GIT = '2.17.1'
77
SVN = '1.9.7'
88
CVSNT = '2.5.04'

0 commit comments

Comments
 (0)