Skip to content
This repository has been archived by the owner on Jun 6, 2022. It is now read-only.

Commit

Permalink
No puts
Browse files Browse the repository at this point in the history
  • Loading branch information
Procrat committed Sep 1, 2015
1 parent dbe7f2f commit c22f522
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,12 @@ class Repository < ActiveRecord::Base

def pull_or_clone
if Dir.exist? path
puts "Checking remote url of #{name}..."
remote_url = `cd #{path} && git remote -v`.split[1]
if remote_url != authenticated_clone_url
puts 'Setting new remote url...'
`cd #{path} && git remote set-url origin #{authenticated_clone_url}`
end

puts "Fetching #{name}..."
ensure_correct_remote_url

logger.info("Fetching #{name}...")
`cd #{path} && git fetch && git reset --hard origin/master`
else
puts "Cloning #{name}..."
logger.info("Cloning #{name}...")
`mkdir -p #{path} && git clone #{authenticated_clone_url} #{path}`
end
end
Expand Down Expand Up @@ -98,4 +93,13 @@ def authenticated_clone_url
$& + Rails.application.secrets.github_token + '@'
end
end

def ensure_correct_remote_url
logger.info("Checking remote url of #{name}...")
remote_url = `cd #{path} && git remote -v`.split[1]
return if remote_url == authenticated_clone_url

logger.info('Setting new remote url...')
`cd #{path} && git remote set-url origin #{authenticated_clone_url}`
end
end

0 comments on commit c22f522

Please sign in to comment.