lib/git_cli/branch.rb in git_cli-0.8.0 vs lib/git_cli/branch.rb in git_cli-0.9.0

- old
+ new

@@ -16,10 +16,12 @@ module GitCli module Branch + + class BranchError < StandardError; end def current_branch check_vcs @@ -48,13 +50,15 @@ # @currBranch = tok[1].strip # break # end #end - [true, res.strip!] + res.strip + #[true, res.strip!] else - [false, res] + raise BranchError, res.strip + #[false, res] end end end # current_branch @@ -68,11 +72,12 @@ st, rb = remote_branches if st br.concat(rb) end - [true, br] + br + #[true, br] end # all_branches def local_branches @@ -93,13 +98,15 @@ b = [] res.strip! res.each_line do |l| b << l.strip end - [true, b] + b + #[true, b] else - [false, res] + raise BranchError, res.strip + #[false, res] end end end # local_branches @@ -123,13 +130,15 @@ res.strip! res.each_line do |l| b << l.strip end - [true, b] + #[true, b] + b else - [false, res] + raise BranchError, res.strip + #[false, res] end end end # remote_branches @@ -149,13 +158,15 @@ cmdln = cmd.join(" ") log_debug "Switch branch : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? - [true, res.strip] + res.strip + #[true, res.strip] else - [false, res] + raise BranchError, res.strip + #[false, res] end end end # switch_branch @@ -178,13 +189,15 @@ cmdln = cmd.join(" ") log_debug "Create branch : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? - [true, res.strip] + res.strip + #[true, res.strip] else - [false, res] + raise BranchError, res.strip + #[false, res] end end end # create_branch @@ -203,13 +216,15 @@ cmdln = cmd.join(" ") log_debug "Download remote branches name : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? - [true, res.strip] + res.strip + #[true, res.strip] else - [false, res] + raise BranchError, res.strip + #[false, res] end end end # download_all_remote_branches_name alias :sync_all_remote_branches_name :download_all_remote_branches_name @@ -230,13 +245,15 @@ cmdln = cmd.join(" ") log_debug "Merge current branch with branch '#{branch}' : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? - [true, res.strip] + res.strip + #[true, res.strip] else - [false, res] + raise BranchError, res.strip + #[false, res] end end end # merge_branch @@ -258,12 +275,14 @@ cmdln = cmd.join(" ") log_debug "Delete branch '#{branch}' : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? - [true, res.strip] + res.strip + #[true, res.strip] else - [false, res] + raise BranchError, res.strip + #[false, res] end end end # delete_branch