Class: BuildTool::VCS::Git
Overview
Implementation for the git-svn version control system (git-scm.org)
Instance Attribute Summary
Attributes inherited from Base
#configuration, #path, #repository
Class Method Summary collapse
Instance Method Summary collapse
-
#checkedout? ⇒ Boolean
Check if the local checkout exists.
-
#fetch ⇒ Object
Fetch from
repository
. - #git(command, wd = path) ⇒ Object
- #info ⇒ Object
-
#init ⇒ Object
Initialize the local repository.
-
#initialize(repository, path) ⇒ Git
constructor
A new instance of Git.
- #name ⇒ Object
- #rebase ⇒ Object
- #remote_branch ⇒ Object
Constructor Details
#initialize(repository, path) ⇒ Git
Returns a new instance of Git.
31 32 33 |
# File 'lib/kde-build/vcs/git.rb', line 31 def initialize( repository, path ) super end |
Class Method Details
.config ⇒ Object
47 48 49 |
# File 'lib/kde-build/vcs/git.rb', line 47 def self.config GitConfiguration end |
Instance Method Details
#checkedout? ⇒ Boolean
Check if the local checkout exists.
calls VCS::Base::checkedout? and checks if there is a ‘.git’ directory at path
55 56 57 58 59 60 61 62 |
# File 'lib/kde-build/vcs/git.rb', line 55 def checkedout? return false if !super if !File.exists? "#{path}/.git" $log.debug("Checkout path #{path} is not a git repo") return false end return true end |
#fetch ⇒ Object
Fetch from repository
Initializes the local clone if it does not exist.
67 68 69 70 71 72 73 74 75 |
# File 'lib/kde-build/vcs/git.rb', line 67 def fetch() if !checkedout? and !$noop init end cmd = "fetch" if ( rc = git( cmd ) ) != 0 raise GitError, "Error while fetching: #{rc}" end end |
#git(command, wd = path) ⇒ Object
39 40 41 |
# File 'lib/kde-build/vcs/git.rb', line 39 def git( command, wd = path ) self.class.execute "git #{command}", wd end |
#info ⇒ Object
108 109 110 111 |
# File 'lib/kde-build/vcs/git.rb', line 108 def info super puts " Remote Branch: #{remote_branch.inspect}" end |
#init ⇒ Object
Initialize the local repository
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/kde-build/vcs/git.rb', line 79 def init # Check if path exists if File.exists? path raise GitSvnError, "Failed to create repository at '#{path}': Path exists" end # Create the directory FileUtils.mkdir_p( File.split(path)[0] ) if !$noop # Initialize the repository if !git( "clone --no-checkout #{repository} #{path}", Pathname.new(path).dirname ) raise GitError, "Error while initializing the repo `git clone --no-checkout '#{repository} #{path}'`: #{$?}" end # Create the local checkout if remote_branch != "master" if !git( "checkout --track -b #{remote_branch} origin/#{remote_branch}", path ) raise GitError, "Error while initializing the repo `checkout --track -b '#{remote_branch} origin/#{remote_branch}'`: #{$?}" end else if !git( "checkout #{remote_branch}", path ) raise GitError, "Error while initializing the repo `git checkout #{remote_branch}'`: #{$?}" end end fetch() end |
#name ⇒ Object
35 36 37 |
# File 'lib/kde-build/vcs/git.rb', line 35 def name "GIT" end |
#rebase ⇒ Object
113 114 115 |
# File 'lib/kde-build/vcs/git.rb', line 113 def rebase return git "rebase origin" end |
#remote_branch ⇒ Object
43 44 45 |
# File 'lib/kde-build/vcs/git.rb', line 43 def remote_branch @configuration.remote_branch end |