Skip to content

Commit 5f7ddcc

Browse files
authored
Merge pull request #120 from blackducksoftware/OTWO-5773
OTWO-5773 Fix for git index.lock issues
2 parents bb099ab + 5808511 commit 5f7ddcc

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

lib/ohloh_scm/git/scm.rb

Lines changed: 6 additions & 10 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 # rubocop:disable Metrics/ClassLength
5+
class Scm < OhlohScm::Scm
66
def initialize(core:, url:, branch_name:, username:, password:)
77
super
88
@branch_name = branch_name || 'master'
@@ -27,7 +27,7 @@ def vcs_path
2727

2828
def clone_or_fetch(remote_scm, callback)
2929
callback.update(0, 1)
30-
if status.branch?(branch_name)
30+
if status.exist? && status.branch?(branch_name)
3131
clean_and_checkout_branch # must be on correct branch, but we want to be careful.
3232
fetch_new_commits(remote_scm)
3333
else
@@ -43,7 +43,7 @@ def fetch_new_commits(remote_scm)
4343
end
4444

4545
def clone_and_create_tracking_branch(remote_scm)
46-
unless status.scm_dir_exist?
46+
unless status.exist?
4747
run "rm -rf '#{url}'"
4848
run "git clone -q -n '#{remote_scm.url}' '#{url}'"
4949
end
@@ -54,16 +54,12 @@ 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-
return unless status.branch?(branch_name)
5857

5958
run "cd '#{url}' && git clean -f -d -x"
60-
clean_git_lock_file
61-
run "cd '#{url}' && git reset --hard HEAD"
62-
run "cd '#{url}' && git checkout #{branch_name} --"
63-
end
59+
return unless status.branch?(branch_name)
6460

65-
def clean_git_lock_file
66-
run "rm #{url}/.git/index.lock" if File.exist?("#{url}/.git/index.lock")
61+
run "cd '#{url}' && git checkout #{branch_name} --"
62+
run "cd '#{url}' && git reset --hard heads/#{branch_name} --"
6763
end
6864

6965
def create_tracking_branch(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.6'
5+
STRING = '3.0.7'
66
GIT = '2.17.1'
77
SVN = '1.9.7'
88
CVSNT = '2.5.04'

0 commit comments

Comments
 (0)