gity 0.1.1 → 0.1.3

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: 8ad3e13e041d3318b74c725c85b3e54ba508e8137339e3f2ca2ef1510360363d
4
- data.tar.gz: 7bc3e2fd3dc5a4b62e32cdb3c5a8f83cf63a225b7516a38c84de7d9d934c85c2
3
+ metadata.gz: 24e3d82d4348b8657a8ffc591187831ab5035bb52f44cc5cf3213a64539af116
4
+ data.tar.gz: 400b059ab5c831620d775995cd52c4830a731fd8c922b742a3001a92c134eedd
5
5
  SHA512:
6
- metadata.gz: d3573cbd151944bc04fc435929f59ac27d165016122fe03a38ef3318299a96fe0ca164a17aaa8eea96e6de45c700765fa14f41ec353e350c668deedb2610577e
7
- data.tar.gz: 47ada26af980984dac10826dcac61bf5b310d8a02ca6c0f4df595fce432467e99b95016c42d06c04d205dd33f058e1af731fc2510cc1d2d65ab9bd6f7758bc5a
6
+ metadata.gz: cc414e26ec6ed146f616dabfdd346c97c54797f9603752665eeb0f1ea8478f59d93a9cc49d243e291e9e8e7cc73871430b0ae8f3ba12216ca5c4c3843a5632c3
7
+ data.tar.gz: 14d24905024c00d7b22d66682b7fd6c9e10913c8cb75d74d588353736475138d12880b56873cecf48e78bb3dc43c07f14626fc91358f2570dee42529c0c984f0
data/exe/gity CHANGED
@@ -2,5 +2,11 @@
2
2
 
3
3
  require_relative '../lib/gity'
4
4
 
5
- Gity::Landing.new.run(Dir.getwd)
5
+ if ARGV.length == 0
6
+ path = Dir.getwd
7
+ else
8
+ path = File.expand_path(ARGV.first)
9
+ end
10
+
11
+ Gity::Landing.new.run(path)
6
12
 
data/lib/gity/common.rb CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+ require_relative 'flash'
2
3
 
3
4
  module Gity
4
5
  module Common
@@ -24,11 +25,22 @@ module Gity
24
25
  opts.each do |f|
25
26
  res = _pastel.send(f, res)
26
27
  end
28
+ #opts.each do |k,v|
29
+ # case k
30
+ # when :color
31
+ # res = _pastel.send(v, res)
32
+ # else
33
+ # end
34
+ #end
27
35
  end
28
36
 
29
37
  " #{res}"
30
38
  end
31
39
 
40
+ def _flash
41
+ Flash.instance
42
+ end
43
+
32
44
  def _operation_done(no_exit = false)
33
45
  no_exit = false if no_exit.nil?
34
46
  if no_exit
data/lib/gity/flash.rb ADDED
@@ -0,0 +1,59 @@
1
+
2
+ require 'singleton'
3
+
4
+ module Gity
5
+ class Flash
6
+ include Singleton
7
+ include TR::CondUtils
8
+
9
+ def add_info(msg)
10
+ info_msg << msg if not_empty?(msg)
11
+ end
12
+
13
+ def add_error(msg)
14
+ error_msg << msg if not_empty?(msg)
15
+ end
16
+
17
+ def add_warning(msg)
18
+ warning_msg << msg if not_empty?(msg)
19
+ end
20
+
21
+ def has_messages?
22
+ not_empty?(info_msg) or not_empty?(error_msg) or not_empty?(warning_msg)
23
+ end
24
+
25
+ def has_info_msg?
26
+ not_empty?(info_msg)
27
+ end
28
+
29
+ def has_err_msg?
30
+ not_empty?(error_msg)
31
+ end
32
+
33
+ def has_warning_msg?
34
+ not_empty?(warning_msg)
35
+ end
36
+
37
+ def info_msg
38
+ if @_infoMsg.nil?
39
+ @_infoMsg = []
40
+ end
41
+ @_infoMsg
42
+ end
43
+
44
+ def error_msg
45
+ if @_errMsg.nil?
46
+ @_errMsg = []
47
+ end
48
+ @_errMsg
49
+ end
50
+
51
+ def warning_msg
52
+ if @_warnMsg.nil?
53
+ @_warnMsg = []
54
+ end
55
+ @_warnMsg
56
+ end
57
+
58
+ end
59
+ end
data/lib/gity/git_log.rb CHANGED
@@ -28,7 +28,7 @@ module Gity
28
28
  entry.id = ll[0]
29
29
  entry.timestamp = ll[1]
30
30
  by = ll[2].split(",")
31
- entry.commit_by = "#{by[0]} <#{by[1]}>"
31
+ entry.commit_by = "#{by[0]} <#{by[1].strip}>"
32
32
  entry.commit_notes = ll[3]
33
33
  entries << entry
34
34
  end
data/lib/gity/landing.rb CHANGED
@@ -28,6 +28,8 @@ module Gity
28
28
  print_header
29
29
  _prmt.puts
30
30
  res = print_overview(@ws, opts) do |ws, files, optts|
31
+ _prmt.puts
32
+ process_flash
31
33
  _prmt.puts
32
34
  prompt_operation(ws, files, optts, &block)
33
35
  end
@@ -40,5 +42,27 @@ module Gity
40
42
 
41
43
  end
42
44
 
45
+ def process_flash
46
+ if Flash.instance.has_messages?
47
+ if Flash.instance.has_info_msg?
48
+ while Flash.instance.has_info_msg?
49
+ _prmt.puts _fmt Flash.instance.info_msg.pop, :magenta
50
+ end
51
+ end
52
+
53
+ if Flash.instance.has_err_msg?
54
+ while Flash.instance.has_err_msg?
55
+ _prmt.puts _fmt Flash.instance.err_msg.pop, :red
56
+ end
57
+ end
58
+
59
+ if Flash.instance.has_warning_msg?
60
+ while Flash.instance.has_warning_msg?
61
+ _prmt.puts _fmt Flash.instance.warning_msg.pop, :bright_yellow
62
+ end
63
+ end
64
+ end
65
+ end
66
+
43
67
  end
44
68
  end
@@ -3,10 +3,13 @@ require_relative '../common'
3
3
 
4
4
  require_relative '../overview'
5
5
 
6
+ require_relative '../status'
7
+
6
8
  module Gity
7
9
  module Operation
8
10
  module Commit
9
11
  include Common
12
+ include Status
10
13
 
11
14
  def commit(ws, files, &block)
12
15
 
@@ -22,8 +25,14 @@ module Gity
22
25
  efiles.sort.each do |f|
23
26
  m.choice f,f.path
24
27
  end
28
+
29
+ # allow to exit without selecting any files
30
+ m.choice "Done", :done
25
31
  end
26
32
 
33
+ sels.delete(:done)
34
+
35
+ # possible no files available to be add to staging as all files already in staging
27
36
  if not_empty?(sels)
28
37
  block.call(:before_add_to_staging, sels) if block
29
38
  st, res = ws.add_to_staging(*sels)
@@ -31,29 +40,36 @@ module Gity
31
40
  raise OperationError, "Adding files to staging failed with error #{res}" if not st
32
41
  end
33
42
 
34
- _cls
35
- print_overview(ws, skip_other_files: true) do |ws, files, opts|
43
+ st = status(ws)
44
+ if st.has_staged?
45
+
46
+ _cls
47
+ print_overview(ws, skip_other_files: true) do |ws, files, opts|
36
48
 
37
- msg = ""
38
- loop do
39
- msg = _prmt.ask(_fmt("\n Commit message (Ctrl-c to go back) : "), required: true)
40
- confirm = _prmt.yes?(_fmt(" Commit message : #{msg}\n Proceed? No to provide a new commit message "))
41
- if confirm
42
- break
49
+ msg = ""
50
+ loop do
51
+ msg = _prmt.ask(_fmt("\n Commit message (Ctrl-c to go back) : "), required: true)
52
+ confirm = _prmt.yes?(_fmt(" Commit message : #{msg}\n Proceed? No to provide a new commit message "))
53
+ if confirm
54
+ break
55
+ end
43
56
  end
44
- end
45
57
 
46
- oldMsg = msg.clone
47
- msg = block.call(:before_commit_message, msg) if block
48
- _logger.debug "Commit message changed by listener. Old '#{oldMsg}' / New '#{msg}' "
49
- st, res = ws.commit(msg)
50
- block.call(:after_commit_message, st, res) if block
51
- raise OperationError, "Commit all failed with error : #{res}" if not st
58
+ oldMsg = msg.clone
59
+ msg = block.call(:before_commit_message, msg) if block
60
+ _logger.debug "Commit message changed by listener. Old '#{oldMsg}' / New '#{msg}' "
61
+ st, res = ws.commit(msg)
62
+ block.call(:after_commit_message, st, res) if block
63
+ raise OperationError, "Commit all failed with error : #{res}" if not st
64
+
65
+ end
52
66
 
67
+ else
68
+ _flash.add_info "No staged file(s) to be committed"
53
69
  end
54
70
 
55
71
  rescue TTY::Reader::InputInterrupt
56
- _prmt.puts _fmt "Commit aborted"
72
+ _flash.add_info "Commit aborted"
57
73
  end
58
74
 
59
75
  end
@@ -31,7 +31,7 @@ module Gity
31
31
  when :commit_all
32
32
  selOpts["Commit all"] = o if files.has_staged? or files.has_modified? or files.has_deleted?
33
33
  when :commit
34
- selOpts["Commit staged"] = o if files.has_staged?
34
+ selOpts["Commit"] = o if files.has_staged? or files.has_new? or files.has_modified?
35
35
  when :add
36
36
  selOpts["Add"] = o if files.has_new?
37
37
  when :ignore
data/lib/gity/overview.rb CHANGED
@@ -24,10 +24,13 @@ module Gity
24
24
  def print_workspace_items(ws, itm, opts = {})
25
25
 
26
26
  opts = {} if opts.nil?
27
+ _prmt.puts _fmt "Workspace path : #{ws.workspace_root}", :bright_yellow
28
+ _prmt.puts
27
29
  title = opts[:title] || "Workspace Status : "
28
30
  _prmt.puts _fmt title
29
31
  branch = ws.current_branch
30
32
  _prmt.puts _fmt "Branch : #{branch}" if not_empty?(branch)
33
+ _prmt.puts
31
34
 
32
35
  mfiles = itm
33
36
 
@@ -75,8 +78,8 @@ module Gity
75
78
  en = GitLogParser.new(logs)
76
79
  _prmt.puts _fmt "Last 3 last commit : "
77
80
  en.entries.each do |e|
78
- _prmt.puts _fmt "#{e.commit_by}\n #{e.timestamp}\n #{e.commit_notes}"
79
- _prmt.puts _fmt "**** ****"
81
+ _prmt.puts _fmt "#{e.commit_by} @ #{e.timestamp}\n\n #{e.commit_notes}"
82
+ _prmt.puts _fmt "\n**** ****"
80
83
  end
81
84
  _prmt.puts
82
85
  true
data/lib/gity/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gity
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-09 00:00:00.000000000 Z
11
+ date: 2023-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toolrack
@@ -122,6 +122,7 @@ files:
122
122
  - exe/gity
123
123
  - lib/gity.rb
124
124
  - lib/gity/common.rb
125
+ - lib/gity/flash.rb
125
126
  - lib/gity/git_log.rb
126
127
  - lib/gity/landing.rb
127
128
  - lib/gity/operation.rb