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_clean? ⇒ Boolean (also: #clean?)
-
#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
#calculate_distance, #conflicted_files, #deleted_files, #is_local_ahead_of_remote?, #is_remote_ahead_of_local?, #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.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/git_cli.rb', line 127 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.
126 127 128 |
# File 'lib/git_cli.rb', line 126 def repos @repos end |
Instance Method Details
#add_repos(repos) ⇒ Object
155 156 157 |
# File 'lib/git_cli.rb', line 155 def add_repos(repos) @repos << repos if not repos.nil? end |
#check_repos ⇒ Object
add_repos
159 160 161 |
# File 'lib/git_cli.rb', line 159 def check_repos raise_if_empty(@repos, "Repositories should not be empty", GitCliException) end |
#is_clean? ⇒ Boolean Also known as: clean?
234 235 236 237 238 239 240 241 |
# File 'lib/git_cli.rb', line 234 def is_clean? nd, nf = new_files md, mf = modified_files dd, df = deleted_files sd, sf = staged_files (nd.length == 0 and nf.length == 0 and md.length == 0 and mf.length == 0 and dd.length == 0 and df.length == 0 and sd.length == 0 and sf.length == 0) end |
#is_repos_exist?(name) ⇒ Boolean
check_repos
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/git_cli.rb', line 163 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?
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/git_cli.rb', line 175 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
217 218 219 220 221 222 223 224 225 |
# File 'lib/git_cli.rb', line 217 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
147 148 149 |
# File 'lib/git_cli.rb', line 147 def path @wsPath end |
#vcs ⇒ Object
151 152 153 |
# File 'lib/git_cli.rb', line 151 def vcs @vcs end |
#workspace_root ⇒ Object
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 213 214 215 |
# File 'lib/git_cli.rb', line 187 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 |