Class: Gvcs::Workspace

Overview

WsCommon

Constant Summary

Constants included from GitCli::Log

GitCli::Log::SIMPLE_LOG_DEFAULT_CONF

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#logs, #show_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

#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

#check_vcs

Methods included from GitCli::Common

#log_debug, #log_error, #log_warn, #os_exec

Constructor Details

#initialize(vcs, path) ⇒ Workspace

Returns a new instance of Workspace.



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/git_cli.rb', line 122

def initialize(vcs, path)

  raise_if_empty(vcs , "VCS cannot be empty", GitCliException)
  raise_if_empty(path, "Workspace path cannot be empty", GitCliException)
  
  @vcs = vcs
  @givenPath = path

  @wsPath = File.expand_path(@givenPath)

  @repos = []

end

Instance Attribute Details

#reposObject

Returns the value of attribute repos.



121
122
123
# File 'lib/git_cli.rb', line 121

def repos
  @repos
end

Instance Method Details

#add_repos(repos) ⇒ Object



144
145
146
# File 'lib/git_cli.rb', line 144

def add_repos(repos)
  @repos << repos if not repos.nil?
end

#check_reposObject

add_repos



148
149
150
# File 'lib/git_cli.rb', line 148

def check_repos
  raise_if_empty(@repos, "Repositories should not be empty", GitCliException)
end

#is_repos_exist?(name) ⇒ Boolean

check_repos

Returns:

  • (Boolean)


152
153
154
155
156
157
158
159
160
161
# File 'lib/git_cli.rb', line 152

def is_repos_exist?(name)
  found = false
  @repos.each do |re|
    if re.name == name
      found = true
      break
    end
  end
  found
end

#is_workspace?Boolean

is_repos_exist?

Returns:

  • (Boolean)


163
164
165
166
# File 'lib/git_cli.rb', line 163

def is_workspace?
  st, res = status
  st 
end

#pathObject

initialize



136
137
138
# File 'lib/git_cli.rb', line 136

def path
  @wsPath
end

#vcsObject



140
141
142
# File 'lib/git_cli.rb', line 140

def vcs
  @vcs
end

#workspace_rootObject



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/git_cli.rb', line 168

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