lib/origen/revision_control/git.rb in origen-0.7.28 vs lib/origen/revision_control/git.rb in origen-0.7.29
- old
+ new
@@ -242,11 +242,26 @@
git("ls-remote --heads #{remote} #{str}", verbose: false).any? do |line|
line =~ /^[0-9a-f]{40}\s+[a-zA-Z]/
end
end
- def initialized?
+ def initialized?(options = {})
+ @hierarchy_searched ||= begin
+ path = @local.dup
+ until path.root? || File.exist?("#{local}/.git")
+ if File.exist?("#{path}/.git")
+ if options[:allow_local_adjustment]
+ @local = path
+ else
+ fail "Requested local repository #{local} is within existing local repository #{path}"
+ end
+ else
+ path = path.parent
+ end
+ end
+ true
+ end
File.exist?("#{local}/.git") &&
git('remote -v', verbose: false).any? { |r| r =~ /#{remote_without_protocol_and_user}/ || r =~ /#{remote_without_protocol_and_user.to_s.gsub(':', "\/")}/ } &&
!git('status', verbose: false).any? { |l| l =~ /^#? ?Initial commit$/ }
end
@@ -307,12 +322,12 @@
def changes_pending_commit?
!(git('status --verbose', verbose: false).last =~ /^(no changes|nothing to commit|nothing added to commit but untracked files present)/)
end
- def initialize_local_dir
+ def initialize_local_dir(options = {})
super
- unless initialized?
+ unless initialized?(options)
Origen.log.debug "Initializing Git workspace at #{local}"
git 'init'
git 'remote remove origin', verbose: false, check_errors: false
git "remote add origin #{remote}"
end