lib/git_local/repository.rb in git_local-0.0.7 vs lib/git_local/repository.rb in git_local-0.0.8

- old
+ new

@@ -4,16 +4,19 @@ end class InvalidArgument < StandardError end - def initialize(org:, repo:, branch:, local_directory:) + GITHUB_HOST = "github.com".freeze + + def initialize(org:, repo:, branch:, local_directory:, host: GITHUB_HOST) check_for_special_characters(org, repo, branch, local_directory) - @org = org - @repo = repo @branch = branch + @host = host @local_directory = local_directory + @org = org + @repo = repo end def get Dir.exist?(path) && new_commit_on_remote? ? reset_to_latest_from_origin : clone_and_checkout end @@ -72,15 +75,15 @@ end end private - attr_reader :org, :repo, :branch, :local_directory + attr_reader :branch, :host, :local_directory, :org, :repo def clone_and_checkout FileUtils.makedirs(repo_path) unless Dir.exist?(repo_path) - popened_io = IO.popen("(cd #{repo_path} && git clone git@github.com:#{org_repo}.git --branch #{branch} --single-branch #{branch} && cd #{path}) 2>&1") + popened_io = IO.popen("(cd #{repo_path} && git clone git@#{host}:#{org_repo}.git --branch #{branch} --single-branch #{branch} && cd #{path}) 2>&1") out = popened_io.map(&:chomp) || [] Process.wait(popened_io.pid) raise NotFound.new.exception(out.join(" ")) unless $?.to_i == 0 end