git_cli 0.11.3 → 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: bc750608285dcc1362ed54813744bc70765f74a808dc3a6f833fa2b846cdf93e
4
- data.tar.gz: 9a686f33dc16a654fc534999098ef7e8981c8ebf5264429ffd837e62cfabd175
3
+ metadata.gz: 5be69142b682051500f560cd461828a05e192cfba2d841c0ca6bf5c88cca8603
4
+ data.tar.gz: 77b4e22ee8abe86cfd5e9e484acc828a8c1f20eb6d5fbb97cc59f6ad0f9bdda6
5
5
  SHA512:
6
- metadata.gz: 1912f145438b920f90efc5cf42b78fe2d2bb163d240ffd5a67124d541529bb7e02e740bf9d5c1ab85e5a94230532739cd5cbe3a05637fd7b9b07a8e5f4a41cb3
7
- data.tar.gz: '060151482263dc869181d9ad369cd8e5b1aec32b126dd67e03a5365d59e45834751a21065ae9e725c2e1b8a977cddc75094d4b1917aa8cf1117c424d4b1e859d'
6
+ metadata.gz: cd03421558a2184ee2d9268940379c5379e560face017047dacac7f6bf5cc26ab2db844213079cfa08cfcf300a04515b4bf00fcde8110bd4cd4fa718ef6d0ee8
7
+ data.tar.gz: 49a04c97c966df79dacbf1a2a94cf884dd8762bffd9a200e6ad21580494481052230e427216abbec1fbb374d7b8993d60ea08ca1af5cdf1c84b246368ce5c3d6
data/.release_history.yml CHANGED
@@ -8,3 +8,5 @@ git_cli:
8
8
  :timestamp: 1676968358.595788
9
9
  - :version: 0.11.2
10
10
  :timestamp: 1676968433.2215726
11
+ - :version: 0.11.3
12
+ :timestamp: 1680769802.83927
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.2)
5
- gvcs
4
+ git_cli (0.12.0)
6
5
  ptools (~> 1.4.0)
7
6
  teLogger
8
7
  toolrack
@@ -10,22 +9,45 @@ PATH
10
9
  GEM
11
10
  remote: https://rubygems.org/
12
11
  specs:
13
- gem-release (2.2.2)
14
- gvcs (0.1.1)
15
- minitest (5.17.0)
12
+ colorize (0.8.1)
13
+ gvcs (0.1.2)
14
+ minitest (5.18.0)
15
+ pastel (0.8.0)
16
+ tty-color (~> 0.5)
16
17
  ptools (1.4.3)
17
18
  rake (12.3.3)
19
+ release-gem (0.1.19)
20
+ colorize
21
+ git_cli
22
+ gvcs
23
+ teLogger
24
+ toolrack
25
+ tty-command
26
+ tty-prompt
18
27
  teLogger (0.2.2)
19
- toolrack (0.21.0)
28
+ toolrack (0.22.1)
29
+ tty-color (0.6.0)
30
+ tty-command (0.10.1)
31
+ pastel (~> 0.8)
32
+ tty-cursor (0.7.1)
33
+ tty-prompt (0.23.1)
34
+ pastel (~> 0.8)
35
+ tty-reader (~> 0.8)
36
+ tty-reader (0.9.0)
37
+ tty-cursor (~> 0.7)
38
+ tty-screen (~> 0.8)
39
+ wisper (~> 2.0)
40
+ tty-screen (0.8.1)
41
+ wisper (2.0.1)
20
42
 
21
43
  PLATFORMS
22
44
  x86_64-linux
23
45
 
24
46
  DEPENDENCIES
25
- gem-release
26
47
  git_cli!
27
48
  minitest (~> 5.0)
28
49
  rake (~> 12.0)
50
+ release-gem
29
51
 
30
52
  BUNDLED WITH
31
53
  2.2.28
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"
@@ -10,3 +10,4 @@ Rake::TestTask.new(:test) do |t|
10
10
  end
11
11
 
12
12
  task :default => :test
13
+ require 'release/gem'
data/git_cli.gemspec CHANGED
@@ -30,10 +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
37
  #spec.add_development_dependency 'devops_assist' #, ">= 0.2.0"
38
- spec.add_development_dependency 'gem-release'
38
+ spec.add_development_dependency 'release-gem'
39
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
@@ -30,11 +30,19 @@ module GitCli
30
30
 
31
31
  # support sort
32
32
  def <=>(val)
33
- @path <=> val.path
33
+ if val.is_a?(VCSItem)
34
+ @path <=> val.path
35
+ else
36
+ false
37
+ end
34
38
  end
35
39
 
36
40
  def ==(val)
37
- @path == val.path
41
+ if val.is_a?(VCSItem)
42
+ @path == val.path
43
+ else
44
+ false
45
+ end
38
46
  end
39
47
  end
40
48
  class NewDir < VCSItem
@@ -185,6 +193,12 @@ module GitCli
185
193
 
186
194
  end
187
195
  end # modified files
196
+ def modified
197
+ modified_files.reverse
198
+ end
199
+ def modFiles
200
+ modified.first
201
+ end
188
202
 
189
203
  def conflicted_files
190
204
 
@@ -221,6 +235,12 @@ module GitCli
221
235
 
222
236
  end
223
237
  end # conflicted files
238
+ def conflicted
239
+ conflicted_files.reverse
240
+ end
241
+ def cftFiles
242
+ conflicted.first
243
+ end
224
244
 
225
245
  def new_files
226
246
 
@@ -257,6 +277,9 @@ module GitCli
257
277
  end
258
278
 
259
279
  end # new_files
280
+ def newFiles
281
+ new_files.reverse.first
282
+ end
260
283
 
261
284
  def deleted_files
262
285
 
@@ -293,6 +316,12 @@ module GitCli
293
316
  end
294
317
 
295
318
  end # deleted_files
319
+ def deleted
320
+ deleted_files.reverse
321
+ end
322
+ def delFiles
323
+ deleted.first
324
+ end
296
325
 
297
326
  def staged_files
298
327
 
@@ -329,6 +358,12 @@ module GitCli
329
358
  end
330
359
 
331
360
  end # staged_files
361
+ def staged
362
+ staged_files.reverse
363
+ end
364
+ def stgFiles
365
+ staged.first
366
+ end
332
367
 
333
368
  def reset_file_changes(path)
334
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.3"
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.3
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
@@ -67,7 +53,7 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: 1.4.0
69
55
  - !ruby/object:Gem::Dependency
70
- name: gem-release
56
+ name: release-gem
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="