class PgBundle::GitSource
The GithubSource
class defines a Github Source
Attributes
branch[R]
Public Class Methods
new(path, branch = 'master')
click to toggle source
Calls superclass method
PgBundle::BaseSource::new
# File lib/pgbundle/git_source.rb, line 7 def initialize(path, branch = 'master') @branch = branch || 'master' super(path) end
Public Instance Methods
clean()
click to toggle source
# File lib/pgbundle/git_source.rb, line 21 def clean FileUtils.remove_dir(clone_dir, true) end
load(host, user, dest)
click to toggle source
# File lib/pgbundle/git_source.rb, line 12 def load(host, user, dest) clone if host == 'localhost' copy_local("#{clone_dir}/", dest) else copy_to_remote(host, user, "#{clone_dir}/", dest) end end
Private Instance Methods
clone()
click to toggle source
# File lib/pgbundle/git_source.rb, line 27 def clone res = %x((rm -rf #{clone_dir} && #{git_command} && rm -rf #{clone_dir}/.git}) 2>&1) unless $?.success? fail GitCommandError, git_command, res end end
clone_dir()
click to toggle source
# File lib/pgbundle/git_source.rb, line 39 def clone_dir @clone_dir ||= Dir.mktmpdir end
git_command()
click to toggle source
git clone user@git-server:project_name.git -b branch_name /some/folder
# File lib/pgbundle/git_source.rb, line 35 def git_command "git clone #{path} -b #{branch} --quiet --depth=1 #{clone_dir}" end