Module: Braid::Operations::Mirror
- Included in:
- Command
- Defined in:
- lib/braid/operations.rb
Instance Method Summary collapse
- #add_config_file ⇒ Object
- #check_merge_status(commit) ⇒ Object
- #create_work_branch ⇒ Object
- #fetch_remote(type, remote) ⇒ Object
- #find_remote(remote) ⇒ Object
- #get_current_branch ⇒ Object
- #get_work_head ⇒ Object
Instance Method Details
#add_config_file ⇒ Object
202 203 204 205 |
# File 'lib/braid/operations.rb', line 202 def add_config_file exec!("git add #{CONFIG_FILE}") true end |
#check_merge_status(commit) ⇒ Object
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/braid/operations.rb', line 207 def check_merge_status(commit) commit = find_git_revision(commit) # tip from spearce in #git: # `test z$(git merge-base A B) = z$(git rev-parse --verify A)` if invoke(:git_merge_base, commit, "HEAD") == commit raise Braid::Commands::MirrorAlreadyUpToDate end true end |
#create_work_branch ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/braid/operations.rb', line 186 def create_work_branch # check if branch exists status, out, err = exec("git branch | grep '#{WORK_BRANCH}'") if status != 0 # then create it msg "Creating work branch '#{WORK_BRANCH}'." exec!("git branch #{WORK_BRANCH}") end true end |
#fetch_remote(type, remote) ⇒ Object
218 219 220 221 222 223 224 225 226 |
# File 'lib/braid/operations.rb', line 218 def fetch_remote(type, remote) msg "Fetching data from '#{remote}'." case type when "git" invoke(:git_fetch, remote) when "svn" invoke(:git_svn_fetch, remote) end end |
#find_remote(remote) ⇒ Object
228 229 230 231 |
# File 'lib/braid/operations.rb', line 228 def find_remote(remote) # TODO clean up and maybe return more information !!File.readlines(".git/config").find { |line| line =~ /^\[(svn-)?remote "#{remote}"\]/ } end |
#get_current_branch ⇒ Object
181 182 183 184 |
# File 'lib/braid/operations.rb', line 181 def get_current_branch status, out, err = exec!("git branch | grep '*'") out[2..-1] end |
#get_work_head ⇒ Object
198 199 200 |
# File 'lib/braid/operations.rb', line 198 def get_work_head find_git_revision(WORK_BRANCH) end |