Class: BuildTool::VCS::GitSvn
- Inherits:
-
Base
- Object
- Base
- BuildTool::VCS::GitSvn
show all
- Defined in:
- lib/build-tool/vcs/git-svn.rb
Overview
Implementation for the git-svn version control system.
Defined Under Namespace
Classes: GitSvnError
Instance Attribute Summary
Attributes inherited from Base
#config
Instance Method Summary
collapse
Methods inherited from Base
#apply_patches_after_rebase?, #local_path, #local_path_exist?, #patches_supported?, #prepare_for_vcs_access, #recipe
Constructor Details
#initialize(*args) ⇒ GitSvn
Returns a new instance of GitSvn.
63
64
65
|
# File 'lib/build-tool/vcs/git-svn.rb', line 63
def initialize( *args )
super( *args )
end
|
Instance Method Details
#[](var) ⇒ Object
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/build-tool/vcs/git-svn.rb', line 174
def[]( var )
case var
when 'external'
return @externals
else
raise NotImplementedError, "#{var}"
end
end
|
#[]=(var, val) ⇒ Object
186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/build-tool/vcs/git-svn.rb', line 186
def[]=( var, val )
case var
when 'external'
tmp = val.split( /#/ )
@externals[tmp[0]] = tmp[1]
else
raise NotImplementedError, "#{var}"
end
end
|
#checkedout? ⇒ Boolean
82
83
84
85
86
87
88
|
# File 'lib/build-tool/vcs/git-svn.rb', line 82
def checkedout?
return false if !local_path_exist?
if !Pathname.new( local_path ).join( ".git" ).exist?
raise Base::VcsError, "Checkout path #{local_path} is not a git repo!"
end
return true
end
|
#clone ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/build-tool/vcs/git-svn.rb', line 90
def clone
if local_path_exist?
raise GitSvnError, "Failed to create repository at '#{local_path}': Path exists"
end
FileUtils.mkdir_p( local_path ) if !$noop
if 0 != ( git_svn "init #{config.repository.url}/#{remote_path}" )
raise GitSvnError, "Error while initializing the repo `git svn init '#{config.repository}/#{remote_path}'`: #{$?}"
end
fetch( "HEAD" )
end
|
103
104
105
|
# File 'lib/build-tool/vcs/git-svn.rb', line 103
def configure
git.configure
end
|
#fetch(revision = nil) ⇒ Object
Fetch from repository
Initializes the local clone if it does not exist.
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/build-tool/vcs/git-svn.rb', line 110
def fetch( revision = nil )
if !checkedout? and !$noop clone
end
if revision
cmd = "fetch -r#{revision}"
else
cmd = "fetch"
end
if ( rc = git_svn( cmd ) ) != 0
raise GitSvnError, "Error while fetching: #{rc}"
end
update_externals
end
|
#fetching_supported? ⇒ Boolean
74
75
76
|
# File 'lib/build-tool/vcs/git-svn.rb', line 74
def fetching_supported?
true
end
|
#gc ⇒ Object
125
126
127
|
# File 'lib/build-tool/vcs/git-svn.rb', line 125
def gc
git.git( "gc" )
end
|
#git ⇒ Object
129
130
131
132
133
134
|
# File 'lib/build-tool/vcs/git-svn.rb', line 129
def git
if @git.nil?
@git = Git.new( config )
end
@git
end
|
#git_svn(command, wd = local_path, &block) ⇒ Object
Call git-svn with command
137
138
139
140
141
142
143
|
# File 'lib/build-tool/vcs/git-svn.rb', line 137
def git_svn( command, wd = local_path, &block )
rc = self.class.execute( "git svn " + command, wd, &block )
if rc != 0
raise GitSvnError, "git svn #{command || "" } failed with error code #{rc}";
end
rc
end
|
#name ⇒ Object
70
71
72
|
# File 'lib/build-tool/vcs/git-svn.rb', line 70
def name
"git-svn"
end
|
#prepare_for_access ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/build-tool/vcs/git-svn.rb', line 145
def prepare_for_access
if config.repository.sshkey
key = config.repository.sshkey
if ! MJ::Tools::SSH::has_key? key.file
logger.info ""
logger.info "#### Adding required ssh-key #{key.file} to ssh-agent."
MJ::Tools::SSH::add_key key.file
end
end
true
end
|
#rebase ⇒ Object
158
159
160
161
162
|
# File 'lib/build-tool/vcs/git-svn.rb', line 158
def rebase
if 0 != ( git.git "rebase #{config.track_branch}" )
raise GitSvnError, "Error while rebasing the repo with `#{config.track_branch}': #{$?}"
end
end
|
#remote_path ⇒ Object
164
165
166
|
# File 'lib/build-tool/vcs/git-svn.rb', line 164
def remote_path
@config.remote_path
end
|
#update_externals ⇒ Object
168
169
170
171
172
|
# File 'lib/build-tool/vcs/git-svn.rb', line 168
def update_externals
config.externals.each do |local, remote|
VCS::Svn::svn( "checkout #{remote}@HEAD #{local}", wd = local_path )
end
end
|