Class: Gvcs::Workspace
- Inherits:
-
Object
- Object
- Gvcs::Workspace
- Includes:
- GitCli::AddCommit, GitCli::Branch, GitCli::Common, GitCli::Delta, GitCli::Diff, GitCli::Ignore, GitCli::Log, GitCli::Pull, GitCli::Push, GitCli::Repos, GitCli::Stash, GitCli::Tags, GitCli::WsCommon, TR::CondUtils
- Defined in:
- lib/git_cli.rb
Overview
WsCommon
Constant Summary
Constants included from GitCli::Log
GitCli::Log::SIMPLE_LOG_DEFAULT_CONF
Instance Attribute Summary collapse
-
#repos ⇒ Object
Returns the value of attribute repos.
Instance Method Summary collapse
- #add_repos(repos) ⇒ Object
-
#check_repos ⇒ Object
add_repos.
-
#initialize(path, vcs = nil) ⇒ Workspace
constructor
A new instance of Workspace.
-
#is_repos_exist?(name) ⇒ Boolean
check_repos.
-
#is_workspace? ⇒ Boolean
is_repos_exist?.
-
#load_remote_to_repos ⇒ Object
workspace_root.
-
#path ⇒ Object
initialize.
- #vcs ⇒ Object
- #workspace_root ⇒ Object
Methods included from GitCli::Stash
#stash_changes, #stash_clear, #stash_list, #stash_remove, #stash_restore, #stash_restore_and_remove, #stash_to_new_branch
Methods included from GitCli::Repos
#add_remote, #remote_config, #remove_remote
Methods included from GitCli::Tags
#all_tags, #checkout_tag, #create_tag, #create_tag_from_commit, #delete_remote_tag, #delete_tag, #fetch_tag_to_local, #show_tag_detail, #tag_info
Methods included from GitCli::Log
Methods included from GitCli::Ignore
#ignore, #ignore_rules, #update_ignore_rules
Methods included from GitCli::Diff
#diff, #diff_branch, #diff_common, #diff_file_with_last_commit, #diff_index_with_last_commit, #diff_working_with_last_commit
Methods included from GitCli::Branch
#all_branches, #create_branch, #current_branch, #delete_branch, #download_all_remote_branches_name, #local_branches, #merge_branch, #remote_branches, #switch_branch
Methods included from GitCli::Pull
Methods included from GitCli::Push
#push_changes, #push_changes_with_tags
Methods included from GitCli::Delta
#conflicted_files, #deleted_files, #modified_files, #new_files, #reset_all_changes, #reset_file_changes, #staged_files, #status
Methods included from GitCli::AddCommit
#add_to_staging, #commit, #commit_all, #remove_from_staging, #remove_from_vcs
Methods included from GitCli::WsCommon
Methods included from GitCli::Common
#log_debug, #log_error, #log_warn, #os_exec
Constructor Details
#initialize(path, vcs = nil) ⇒ Workspace
Returns a new instance of Workspace.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/git_cli.rb', line 124 def initialize(path, vcs = nil) #raise_if_empty(vcs , "VCS cannot be empty", GitCliException) raise_if_empty(path, "Workspace path cannot be empty", GitCliException) if is_empty?(vcs) @vcs = Gvcs::Vcs.new else @vcs = vcs end #@vcs = vcs @givenPath = path @wsPath = File.(@givenPath) @repos = [] end |
Instance Attribute Details
#repos ⇒ Object
Returns the value of attribute repos.
123 124 125 |
# File 'lib/git_cli.rb', line 123 def repos @repos end |
Instance Method Details
#add_repos(repos) ⇒ Object
152 153 154 |
# File 'lib/git_cli.rb', line 152 def add_repos(repos) @repos << repos if not repos.nil? end |
#check_repos ⇒ Object
add_repos
156 157 158 |
# File 'lib/git_cli.rb', line 156 def check_repos raise_if_empty(@repos, "Repositories should not be empty", GitCliException) end |
#is_repos_exist?(name) ⇒ Boolean
check_repos
160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/git_cli.rb', line 160 def is_repos_exist?(name) found = false load_remote_to_repos @repos.each do |re| if re.name == name found = true break end end found end |
#is_workspace? ⇒ Boolean
is_repos_exist?
172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/git_cli.rb', line 172 def is_workspace? begin status true rescue GitDeltaError => ex log_debug ex. false end #st, res = status #st end |
#load_remote_to_repos ⇒ Object
workspace_root
214 215 216 217 218 219 220 221 222 |
# File 'lib/git_cli.rb', line 214 def load_remote_to_repos conf = remote_config conf.each do |k,v| repo = Gvcs::Repository.new(k, v.values.first) repo.support_fetch if v.keys.include?("fetch") repo.support_push if v.keys.include?("push") add_repos(repo) end end |
#path ⇒ Object
initialize
144 145 146 |
# File 'lib/git_cli.rb', line 144 def path @wsPath end |
#vcs ⇒ Object
148 149 150 |
# File 'lib/git_cli.rb', line 148 def vcs @vcs end |
#workspace_root ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/git_cli.rb', line 184 def workspace_root if (@wsRoot.nil? or (@wsRoot[0] == false)) check_vcs cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "rev-parse --show-toplevel" cmdln = cmd.join(" ") log_debug "Workspace root: #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? @wsRoot = [true, res] else @wsRoot = [false, res] end end end @wsRoot end |