git_cli 0.11.4 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c844000e4bc30d57687dc1e43d0fc0e46744db06376e00508c6d534be047d54
4
- data.tar.gz: 54ab8c78a819454e0d037c8b73b66003757fc735e828700749bf8010504233c2
3
+ metadata.gz: 5be69142b682051500f560cd461828a05e192cfba2d841c0ca6bf5c88cca8603
4
+ data.tar.gz: 77b4e22ee8abe86cfd5e9e484acc828a8c1f20eb6d5fbb97cc59f6ad0f9bdda6
5
5
  SHA512:
6
- metadata.gz: 20314f09b8b43ea58b8e19e7fc9f9260622b45b9c63ee84b754f0f59ebe52e89b41142c6c2df9e98480d6ec1807e9f814877c4f43344b9b6bbcd27952c4d1c12
7
- data.tar.gz: 7054bf58a5bb2fb0221d5b6dbf5c28be0371e0f1a02e63ab8d47765c04a77e2a707e770da14c3ec2089844998c15ddbe0e40b05c410092ed640782a9fc88d0cd
6
+ metadata.gz: cd03421558a2184ee2d9268940379c5379e560face017047dacac7f6bf5cc26ab2db844213079cfa08cfcf300a04515b4bf00fcde8110bd4cd4fa718ef6d0ee8
7
+ data.tar.gz: 49a04c97c966df79dacbf1a2a94cf884dd8762bffd9a200e6ad21580494481052230e427216abbec1fbb374d7b8993d60ea08ca1af5cdf1c84b246368ce5c3d6
data/Gemfile CHANGED
@@ -6,4 +6,3 @@ gemspec
6
6
  gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.0"
8
8
 
9
- #gem 'gvcs', git: 'gvcs', branch: 'master'
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_cli (0.11.4)
5
- gvcs
4
+ git_cli (0.12.0)
6
5
  ptools (~> 1.4.0)
7
6
  teLogger
8
7
  toolrack
@@ -11,25 +10,13 @@ GEM
11
10
  remote: https://rubygems.org/
12
11
  specs:
13
12
  colorize (0.8.1)
14
- devops_assist (0.3.11)
15
- git_cli
16
- git_cli_prompt (~> 0.3.3)
17
- gvcs
18
- teLogger
19
- toolrack
20
- tty-prompt
21
- gem-release (2.2.2)
22
- git_cli_prompt (0.3.4)
23
- teLogger
24
- toolrack
25
- tty-prompt
26
13
  gvcs (0.1.2)
27
14
  minitest (5.18.0)
28
15
  pastel (0.8.0)
29
16
  tty-color (~> 0.5)
30
17
  ptools (1.4.3)
31
18
  rake (12.3.3)
32
- release-gem (0.1.10)
19
+ release-gem (0.1.19)
33
20
  colorize
34
21
  git_cli
35
22
  gvcs
@@ -38,7 +25,7 @@ GEM
38
25
  tty-command
39
26
  tty-prompt
40
27
  teLogger (0.2.2)
41
- toolrack (0.22.0)
28
+ toolrack (0.22.1)
42
29
  tty-color (0.6.0)
43
30
  tty-command (0.10.1)
44
31
  pastel (~> 0.8)
@@ -57,8 +44,6 @@ PLATFORMS
57
44
  x86_64-linux
58
45
 
59
46
  DEPENDENCIES
60
- devops_assist
61
- gem-release
62
47
  git_cli!
63
48
  minitest (~> 5.0)
64
49
  rake (~> 12.0)
data/README.md CHANGED
@@ -11,52 +11,126 @@ This codes are tested using git version 2.25.1, Linux x86\_64
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'gvcs'
15
14
  gem 'git_cli'
16
15
  ```
17
16
 
18
17
  And then execute:
19
18
 
20
- $ bundle install
19
+ $ bundle install
21
20
 
22
21
  Or install it yourself as:
23
22
 
24
- $ gem install gvcs
25
23
  $ gem install git_cli
26
24
 
27
25
  ## Usage
28
26
 
29
- This gem is intended to be the provider for Gvcs generic API. It is used together with [Gvcs](https://github.com/chrisliaw/gvcs).
30
-
31
27
  Example usage:
32
28
 
33
29
  ```ruby
34
- require 'gvcs'
35
- # require git_cli after gvcs because git_cli will initialize the gvcs classes with appropriate methods
36
30
  require 'git_cli'
37
31
 
38
- # Loading the provider.
39
- # in this case is git_cli
32
+ # Gvcs is artificial namespace to shield the actual
33
+ # GitCli package name. It is designed so that if we
34
+ # have another VCS coming all client code can remain
35
+ # unchanged since the specific package name is not
36
+ # being used in client application. The new VCS provider
37
+ # can just provide all functions via the interface
38
+ # Only draw back is this cannot run multiple VCS at the
39
+ # same time
40
+ #
41
+ # vcs is encapsulation of general functions (read below)
40
42
  vcs = Gvcs::Vcs.new
41
43
  vcs.init(path) # init workspace at the given path
44
+ vcs.clone("/source/repos", "/destination/repos") # clone a project
42
45
 
43
- @ws = Gvcs::Workspace.new(vcs, path)
44
- # @ws now can invoke all supported git operations
46
+ workspace = Gvcs::Workspace.new(vcs, "/any/git/repository")
47
+ # workspace now can invoke all supported git operations
45
48
 
46
49
  ```
47
-
48
-
49
- ## Development
50
-
51
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
-
53
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
-
55
- ## Contributing
56
-
57
- Bug reports and pull requests are welcome on GitHub at https://github.com/chrisliaw/git_cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/chrisliaw/git_cli/blob/master/CODE_OF_CONDUCT.md).
58
-
59
-
60
- ## Code of Conduct
61
50
 
62
- Everyone interacting in the GitCli project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/chrisliaw/git_cli/blob/master/CODE_OF_CONDUCT.md).
51
+ ## Supported GIT Operation
52
+
53
+ The following operations are supported on the git command line:
54
+ - Generall functions (to make a directory become git workspace)
55
+ - vcs.init("/path/to/new/workspace")
56
+ - vcs.clone("/source/repos","/path/to/workspace")
57
+ - Workspace command
58
+ - workspace.root\_path # git rev-parse --show-toplevel
59
+ - workspace.is\_workspace? # call git status see if error thrown
60
+ - workspace.repos # returns list of remote repositories
61
+ - workspace.clean? # return true if there is no new,deleted,modified and staged files
62
+ - workspace.add("/path/a","/path/b","/path/c/a") # git add
63
+ - workspace.remove\_staging("/path/a","/path/b","/path/c/a") # git reset
64
+ - workspace.remove\_vcs("/path/a","/path/b","/path/c/a") # git rm --cached
65
+ - workspace.commit("commit message", { files: ["/path/a"."/path/b"] }) # git commit -m
66
+ - workspace.commit\_all("commit message") # git commit -am
67
+ - workspace.status # git status [Returns list of GitCli::Delta::VCSItem carries attributes @path, @full and @type]
68
+ - workspace.modified\_files # git diff --name-only --diff-filter=M [returns modified directories and files in an array]
69
+ - workspace.conflicted\_files # git diff --name-only --diff-filter=U [returns conflicted directories and files in an array]
70
+ - workspace.new\_files # git ls-files --others --exclude-standard --directory [returns new directories and files (non tracked) in an array]
71
+ - workspace.deleted\_files # git ls-files -d [returns deleted directories and files in an array]
72
+ - workspace.staged\_files # git diff --name-only --cached [returns staged directories and files in an array]
73
+ - workspace.reset\_file\_changes("/path/to/file") # git checkout --
74
+ - workspace.reset\_all\_changes # git reset --hard
75
+ - workspace.calculat\_distance("origin/HEAD","HEAD") # git rev-list 'origin/HEAD'..'HEAD' --count [returns integer value how far is it]
76
+ - workspace.is\_local\_ahead\_of\_remote?("origin/HEAD","branch-main") # aggregated from calculate\_distance() with default _to_ value fixed at "HEAD" [returns boolean]
77
+ - workspace.is\_remote\_ahead\_of\_local?("origin/HEAD","branch-main") # aggregated from calculate\_distance() with default _from_ value fixed at "HEAD" [returns boolean]
78
+ - workspace.push("origin","master") # git push origin master
79
+ - workspace.push\_with\_tags("origin","master") # git push origin master --tags
80
+ - workspace.pull("origin","master") # git pull
81
+ - workspace.current\_branch # git branch --show-current [returns branch name]
82
+ - workspace.local\_branches # git branch [return local branches in an array]
83
+ - workspace.remote\_branches # git branch -r [return remote branches in an array]
84
+ - workspace.all\_branches # concate output of local\_branches and remote\_branches [returns array]
85
+ - workspace.switch\_branch("new-branch") # git checkout new-branch
86
+ - workspace.create\_branch("new-branch") # git branch new-branch
87
+ - workspace.download\_all\_remote\_branches\_name # git fetch -all
88
+ - workspace.merge\_branch("development") # git merge development
89
+ - workspace.delete\_branch("development") # git branch -d development
90
+ - workspace.diff # git diff
91
+ - workspace.diff\_file("/path/a") # git diff /path/a
92
+ - workspace.diff\_branch("master/HEAD","development/HEAD") # git diff master/HEAD..development/HEAD
93
+ - workspace.diff\_working\_with\_last\_commit # git diff HEAD^ HEAD
94
+ - workspace.diff\_index\_with\_last\_commit # git diff --cached
95
+ - workspace.ignore("/path/a","/path/b") # Append entries into .gitignore file
96
+ - workspace.ignore\_rules # read the .gitignore files and returns its content in an array
97
+ - workspace.update\_ignore\_rules("\*.log") # add non file entries into .gitignore
98
+ - workspace.show\_log(commit\_id) # git show commit\_id
99
+ - workspace.all\_tags # git tag [returns array]
100
+ - workspace.tag\_info("tag name", "%H|%ad|%an|%s") # git show tag\_name --format="%H|%ad|%an|%s"
101
+ - workspace.create\_tag(tagname) # git tag tagname
102
+ - workspace.create\_tag(tagname, message) # git tag -a tagname -m message
103
+ - workspace.create\_tag\_from\_commit(tagname, commit) # git tag -a tagname commit
104
+ - workspace.create\_tag\_from\_commit(tagname, commit, message) # git tag -a tagname -m message commit
105
+ - workspace.fetch\_tag\_to\_local # git fetch --all --tags
106
+ - workspace.show\_tag\_detail(tagname) # git show tagname
107
+ - workspace.delete\_tag(tagname) # git tag -d tagname
108
+ - workspace.delete\_remote\_tag("origin","tagname") # git push origin --delete tagname
109
+ - workspace.checkout\_tag(tagname, branch) # git checkout tags/tagname -b branch
110
+ - workspace.tag\_points\_at?("HEAD") # git tag --points-at HEAD [Return boolean]
111
+ - workspace.remote\_config # git remote -vv [return Hash with repos name as key, points to hash with "push" or "fetch" as key]
112
+ - workspace.add\_remote(name, url) # git remote add name url
113
+ - workspace.remove\_remote(name) # git remote remove name
114
+ - workspace.stash\_changes(msg) # git stash save "msg"
115
+ - workspace.stash\_all\_chanegs(msg) # git stash save --include-untracked
116
+ - workspace.stash\_all\_chanegs(msg, true) # git stash save --include-untracked(-u) --all(-a)
117
+ - workspace.stash\_list # git stash list [returns boolean and hash of stash info]
118
+ - workspace.stash\_restore # git stash apply
119
+ - workspace.stash\_restore(id) # git stash apply id --> ID can be obtained from stash\_list. Something like "stash@{0}"
120
+ - workspace.stash\_restore\_and\_remove # git stash pop
121
+ - workspace.stash\_restore\_and\_remove(id) # git stash pop id --> ID can be obtained from stash\_list. Something like "stash@{0}"
122
+ - workspace.stash\_to\_new\_branch(branch) # git stash branch
123
+ - workspace.stash\_to\_new\_branch(branch, id) # git stash branch id
124
+ - workspace.stash\_clear # git stash clear
125
+ - workspace.stash\_remove # git stash drop
126
+ - workspace.stash\_remove(id) # git stash drop id
127
+
128
+
129
+
130
+ ## Return Value
131
+
132
+ Unless otherwise stated, the API shall return an array, with 1st element is the boolean status value running the command line (taken from $?) and 2nd element shall be the standard output of the running command. Note though all command was run with flag '2>&1' which effectively redirected the STDERR to STDOUT which should be captured by the program.
133
+
134
+ This is due to all running of command line is via the backtick (\`) method. The reason to use this is backtick allow interaction with user. If there is an input needed, backtick will actually wait user input at the prompt, although not ideal, but it is the simplest and easiest for now.
135
+
136
+
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
- require "devops_assist"
4
+ #require "devops_assist"
5
5
 
6
6
  Rake::TestTask.new(:test) do |t|
7
7
  t.libs << "test"
data/git_cli.gemspec CHANGED
@@ -30,11 +30,10 @@ Gem::Specification.new do |spec|
30
30
  #spec.add_dependency "tlogger"
31
31
  spec.add_dependency 'teLogger'
32
32
  spec.add_dependency "toolrack"
33
- spec.add_dependency "gvcs"
33
+ #spec.add_dependency "gvcs"
34
34
  spec.add_dependency "ptools", "~> 1.4.0"
35
35
 
36
36
  #spec.add_development_dependency 'devops_helper' #, ">= 0.2.0"
37
- spec.add_development_dependency 'devops_assist' #, ">= 0.2.0"
38
- spec.add_development_dependency 'gem-release'
37
+ #spec.add_development_dependency 'devops_assist' #, ">= 0.2.0"
39
38
  spec.add_development_dependency 'release-gem'
40
39
  end
@@ -25,15 +25,14 @@ module GitCli
25
25
 
26
26
  raise_if_empty(paths, "Given path to add is empty", GitCliException)
27
27
 
28
- paths = [paths] if not paths.is_a?(Array)
29
-
30
28
  cmd = []
31
29
  cmd << "cd"
32
30
  cmd << @wsPath
33
31
  cmd << "&&"
34
32
  cmd << @vcs.exe_path
35
33
  cmd << "add"
36
- cmd.append(paths.join(" "))
34
+
35
+ cmd.append(GitCli::Workspace.args_to_string_array(paths).join(" "))
37
36
  cmdln = cmd.join " "
38
37
 
39
38
  log_debug "Add : #{cmdln}"
@@ -51,20 +50,19 @@ module GitCli
51
50
  alias :add :add_to_staging
52
51
  alias :add_staging :add_to_staging
53
52
 
54
- def remove_from_staging(paths)
53
+ def remove_from_staging(*paths)
55
54
  check_vcs
56
55
 
57
56
  raise_if_empty(paths, "Given path to reset is empty", GitCliException)
58
57
 
59
- paths = [paths] if not paths.is_a?(Array)
60
-
61
58
  cmd = []
62
59
  cmd << "cd"
63
60
  cmd << @wsPath
64
61
  cmd << "&&"
65
62
  cmd << @vcs.exe_path
66
63
  cmd << "reset"
67
- cmd.append(paths)
64
+
65
+ cmd.append(GitCli::Workspace.args_to_string_array(paths))
68
66
  cmdln = cmd.join " "
69
67
 
70
68
  log_debug "reset : #{cmdln}"
@@ -76,21 +74,20 @@ module GitCli
76
74
  end # remove_from_staging
77
75
  alias :remove_staging :remove_from_staging
78
76
 
79
- def remove_from_vcs(paths)
77
+ def remove_from_vcs(*paths)
80
78
 
81
79
  check_vcs
82
80
 
83
81
  raise_if_empty(paths, "Given path to remove from VCS is empty", GitCliException)
84
82
 
85
- paths = [paths] if not paths.is_a?(Array)
86
-
87
83
  cmd = []
88
84
  cmd << "cd"
89
85
  cmd << @wsPath
90
86
  cmd << "&&"
91
87
  cmd << @vcs.exe_path
92
88
  cmd << "rm --cached"
93
- cmd.append(paths)
89
+
90
+ cmd.append(GitCli::Workspace.args_to_string_array(paths))
94
91
  cmdln = cmd.join " "
95
92
 
96
93
  log_debug "Remove from git version control : #{cmdln}"
@@ -100,6 +97,7 @@ module GitCli
100
97
  end
101
98
 
102
99
  end # remove_from_vcs
100
+ alias :remove_vcs :remove_from_vcs
103
101
 
104
102
  def commit(message, opts = { })
105
103
  check_vcs
@@ -116,7 +114,7 @@ module GitCli
116
114
  cmd << @vcs.exe_path
117
115
  cmd << "commit"
118
116
  if not_empty?(files)
119
- cmd << files.join(" ")
117
+ cmd << GitCli::Workspace.args_to_string_array(files).join(" ")
120
118
  end
121
119
  cmd << "-m"
122
120
  cmd << "\"#{msg}\""
data/lib/git_cli/delta.rb CHANGED
@@ -193,6 +193,12 @@ module GitCli
193
193
 
194
194
  end
195
195
  end # modified files
196
+ def modified
197
+ modified_files.reverse
198
+ end
199
+ def modFiles
200
+ modified.first
201
+ end
196
202
 
197
203
  def conflicted_files
198
204
 
@@ -229,6 +235,12 @@ module GitCli
229
235
 
230
236
  end
231
237
  end # conflicted files
238
+ def conflicted
239
+ conflicted_files.reverse
240
+ end
241
+ def cftFiles
242
+ conflicted.first
243
+ end
232
244
 
233
245
  def new_files
234
246
 
@@ -265,6 +277,9 @@ module GitCli
265
277
  end
266
278
 
267
279
  end # new_files
280
+ def newFiles
281
+ new_files.reverse.first
282
+ end
268
283
 
269
284
  def deleted_files
270
285
 
@@ -301,6 +316,12 @@ module GitCli
301
316
  end
302
317
 
303
318
  end # deleted_files
319
+ def deleted
320
+ deleted_files.reverse
321
+ end
322
+ def delFiles
323
+ deleted.first
324
+ end
304
325
 
305
326
  def staged_files
306
327
 
@@ -337,6 +358,12 @@ module GitCli
337
358
  end
338
359
 
339
360
  end # staged_files
361
+ def staged
362
+ staged_files.reverse
363
+ end
364
+ def stgFiles
365
+ staged.first
366
+ end
340
367
 
341
368
  def reset_file_changes(path)
342
369
 
@@ -40,12 +40,13 @@ module GitCli
40
40
  File.open(rulesFile,"r") do |f|
41
41
  @cont = f.read
42
42
  end
43
- @cont
43
+ #@cont
44
+ @cont.each_line.to_a.delete_if { |l| l.strip.empty? }
44
45
  else
45
- ""
46
+ []
46
47
  end
47
48
  else
48
- ""
49
+ []
49
50
  end
50
51
  end
51
52
 
data/lib/git_cli/init.rb CHANGED
@@ -23,7 +23,7 @@ require_relative 'global'
23
23
  module GitCli
24
24
  module Init
25
25
 
26
- def init(path)
26
+ def init(path, bare = false)
27
27
  # from Core module
28
28
  gpath = exe_path
29
29
 
@@ -32,6 +32,9 @@ module GitCli
32
32
  #cmd << "&&"
33
33
  cmd << gpath
34
34
  cmd << "init"
35
+ if bare
36
+ cmd << "--bare"
37
+ end
35
38
  cmd << File.expand_path(path)
36
39
 
37
40
  cmdln = cmd.join(" ")
data/lib/git_cli/push.rb CHANGED
@@ -15,11 +15,13 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
 
18
+ require_relative 'branch'
18
19
 
19
20
  module GitCli
20
21
  module Push
22
+ include Branch
21
23
 
22
- def push_changes(repos, branch = "master")
24
+ def push_changes(repos, branch = nil)
23
25
  check_vcs
24
26
  #check_repos
25
27
  raise_if_empty(repos, "Push to repository name cannot be empty", GitCliException)
@@ -33,6 +35,9 @@ module GitCli
33
35
  cmd << @vcs.exe_path
34
36
  cmd << "push"
35
37
  cmd << repos
38
+ if is_empty?(branch)
39
+ branch = current_branch
40
+ end
36
41
  cmd << branch
37
42
 
38
43
  cmdln = cmd.join " "
@@ -44,7 +49,7 @@ module GitCli
44
49
  end # push_changes
45
50
  alias :push :push_changes
46
51
 
47
- def push_changes_with_tags(repos, branch = "master")
52
+ def push_changes_with_tags(repos, branch = nil)
48
53
  check_vcs
49
54
  #check_repos
50
55
  raise_if_empty(repos, "Push to repository name cannot be empty", GitCliException)
@@ -58,6 +63,9 @@ module GitCli
58
63
  cmd << @vcs.exe_path
59
64
  cmd << "push"
60
65
  cmd << repos
66
+ if is_empty?(branch)
67
+ branch = current_branch
68
+ end
61
69
  cmd << branch
62
70
  cmd << "--tags"
63
71
 
data/lib/git_cli/stash.rb CHANGED
@@ -24,9 +24,10 @@ module GitCli
24
24
  # due to various reason. i.e. urgent fix, hot patch etc
25
25
 
26
26
  #
27
- # Save all the temporary changes so branch switch is possible
27
+ # Save all changes so branch switch is possible
28
+ # Excluding untracked files
28
29
  #
29
- def stash_changes(msg, include_untracked = true)
30
+ def stash_changes(msg)
30
31
 
31
32
  check_vcs
32
33
 
@@ -44,20 +45,59 @@ module GitCli
44
45
  cmd << msg2
45
46
  end
46
47
 
47
- # always include untracked since the stash condition
48
- # is played using scenario under development and must
49
- # switch branch for any reasons
50
- if include_untracked
51
- cmd << "--include-untracked"
48
+ cmdln = cmd.join(" ")
49
+ log_debug "Stash changes : #{cmdln}"
50
+ res = os_exec(cmdln) do |st, res|
51
+ [st.success?, res]
52
+ end
53
+
54
+ end # stash changes - changed files only
55
+
56
+ #
57
+ # Save all the temporary changes so the workspace will be clean
58
+ # for other operation
59
+ #
60
+ # This operation only stash: modified files (already in git workspace)
61
+ # and new files (not in git workspace yet)
62
+ #
63
+ # If flag includes_ignore_file is true, include ignored file too
64
+ #
65
+ def stash_all_changes(msg, includes_ignore_file = false)
66
+
67
+ check_vcs
68
+
69
+ cmd = []
70
+ cmd << "cd"
71
+ cmd << @wsPath
72
+ cmd << "&&"
73
+ cmd << @vcs.exe_path
74
+ cmd << "stash"
75
+ cmd << "save"
76
+
77
+ if not_empty?(msg)
78
+ # have to escape the message for command line purposes
79
+ msg2 = msg.gsub("\"","\\\"").gsub("\\","\\\\")
80
+ cmd << msg2
81
+ end
82
+
83
+ cmd << "--include-untracked"
84
+
85
+ if includes_ignore_file == true
86
+ cmd << "--all"
52
87
  end
53
88
 
54
89
  cmdln = cmd.join(" ")
55
- log_debug "Stash changes : #{cmdln}"
90
+ if includes_ignore_file
91
+ log_debug "Stash all changes (including untracked and ignored files) : #{cmdln}"
92
+ else
93
+ log_debug "Stash all changes (including untracked files) : #{cmdln}"
94
+ end
56
95
  res = os_exec(cmdln) do |st, res|
57
96
  [st.success?, res]
58
97
  end
59
98
 
60
- end # stash changes
99
+ end # stash all changes - including untrack files
100
+
61
101
 
62
102
  #
63
103
  # List all saved temporary changes
@@ -162,7 +202,7 @@ module GitCli
162
202
  cmd << @wsPath
163
203
  cmd << "&&"
164
204
  cmd << @vcs.exe_path
165
- cmd << "stash branch"
205
+ cmd << "stash"
166
206
  cmd << branch
167
207
 
168
208
  if not is_empty?(id)
data/lib/git_cli/tags.rb CHANGED
@@ -37,7 +37,7 @@ module GitCli
37
37
  res = os_exec(cmdln) do |st, res|
38
38
 
39
39
  if st.success?
40
- res.strip
40
+ res.strip.each_line.to_a.map { |v| v.strip }
41
41
  #[true, res.strip!]
42
42
  else
43
43
  raise TagError, res
@@ -300,7 +300,10 @@ module GitCli
300
300
  cmd << @wsPath
301
301
  cmd << "&&"
302
302
  cmd << @vcs.exe_path
303
- cmd << "push origin --delete"
303
+ cmd << "push"
304
+ cmd << repos
305
+ cmd << "--delete"
306
+ #cmd << "push origin --delete"
304
307
  cmd << tag
305
308
 
306
309
  cmdln = cmd.join(" ")
@@ -15,5 +15,5 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  module GitCli
18
- VERSION = "0.11.4"
18
+ VERSION = "0.12.0"
19
19
  end
data/lib/git_cli.rb CHANGED
@@ -85,9 +85,12 @@ module GitCli
85
85
  def dry_run
86
86
  @dry_run.nil? ? false : @dry_run
87
87
  end
88
+
88
89
  end # common operations
89
90
 
90
- class Gvcs::Vcs
91
+ #class Gvcs::Vcs
92
+ class Vcs
93
+ include TR::CondUtils
91
94
  include GitCli::Common
92
95
  include GitCli::GitCore
93
96
  include GitCli::Init
@@ -118,7 +121,9 @@ module GitCli
118
121
  end
119
122
  end # WsCommon
120
123
 
121
- class Gvcs::Workspace
124
+ #class Gvcs::Workspace
125
+ class Workspace
126
+ include TR::CondUtils
122
127
  include GitCli::Common
123
128
  include WsCommon
124
129
  include GitCli::AddCommit
@@ -214,9 +219,11 @@ module GitCli
214
219
  res = os_exec(cmdln) do |st, res|
215
220
 
216
221
  if st.success?
217
- @wsRoot = [true, res.strip]
222
+ @wsRoot = res.strip
223
+ #@wsRoot = [true, res.strip]
218
224
  else
219
- @wsRoot = [false, res.strip]
225
+ raise GitCliException, "Failure executing : #{cmdln} \nError was : #{res.strip}"
226
+ #@wsRoot = [false, res.strip]
220
227
  end
221
228
  end
222
229
 
@@ -225,6 +232,7 @@ module GitCli
225
232
  @wsRoot
226
233
 
227
234
  end # workspace_root
235
+ alias_method :root_path, :workspace_root
228
236
 
229
237
  def load_remote_to_repos
230
238
  conf = remote_config
@@ -252,11 +260,30 @@ module GitCli
252
260
  (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)
253
261
  end
254
262
  alias_method :clean?, :is_clean?
263
+ alias_method :clear?, :is_clean?
264
+
265
+ def self.args_to_string_array(*args)
266
+ res = []
267
+ args.each do |e|
268
+ case e
269
+ when Delta::VCSItem
270
+ res << e.path
271
+ when Array
272
+ res.concat(args_to_string_array(*e))
273
+ when String
274
+ res << e
275
+ else
276
+ res << e.to_s
277
+ end
278
+ end
279
+ res
280
+ end
255
281
 
256
282
  end # Gvcs::Workspace
257
283
 
258
284
 
259
- class Gvcs::Repository
285
+ #class Gvcs::Repository
286
+ class Repository
260
287
 
261
288
  attr_reader :sslVerify
262
289
  attr_reader :name, :url
@@ -294,3 +321,9 @@ module GitCli
294
321
  end # repository
295
322
 
296
323
  end
324
+
325
+ # backward compatibility
326
+ Gvcs::Vcs = GitCli::Vcs
327
+ Gvcs::Workspace = GitCli::Workspace
328
+ Gvcs::Repository = GitCli::Repository
329
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.4
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Liaw
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-06 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: teLogger
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: gvcs
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: ptools
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,34 +52,6 @@ dependencies:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: 1.4.0
69
- - !ruby/object:Gem::Dependency
70
- name: devops_assist
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: gem-release
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
55
  - !ruby/object:Gem::Dependency
98
56
  name: release-gem
99
57
  requirement: !ruby/object:Gem::Requirement