gity 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ad3e13e041d3318b74c725c85b3e54ba508e8137339e3f2ca2ef1510360363d
4
- data.tar.gz: 7bc3e2fd3dc5a4b62e32cdb3c5a8f83cf63a225b7516a38c84de7d9d934c85c2
3
+ metadata.gz: a7b88428dddbf037a5df49d58554541add9012728a718fb0af4f746915d7f329
4
+ data.tar.gz: 1f9f993d3c332212a3e2e2e3d2a18447c98ae6cced9bea174ad3b9d80b77bf9e
5
5
  SHA512:
6
- metadata.gz: d3573cbd151944bc04fc435929f59ac27d165016122fe03a38ef3318299a96fe0ca164a17aaa8eea96e6de45c700765fa14f41ec353e350c668deedb2610577e
7
- data.tar.gz: 47ada26af980984dac10826dcac61bf5b310d8a02ca6c0f4df595fce432467e99b95016c42d06c04d205dd33f058e1af731fc2510cc1d2d65ab9bd6f7758bc5a
6
+ metadata.gz: 4f9c78b33bc01121878c0424f7b7755154719fd801e1a334f889372b5694d27df9207a4a8e7bb064390a5ba60b861fb98c6b3f225b41cd0c11337617fc226aef
7
+ data.tar.gz: c67f13bb05a7f2c157e495d07ea1d68f99022b360da5479ad8cf6eeab69b5b51c9c621828824995c3f7fbe3bf56e186d27c704a63ea5b28c26ca906155990ccb
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
@@ -29,6 +30,10 @@ module Gity
29
30
  " #{res}"
30
31
  end
31
32
 
33
+ def _flash
34
+ Flash.instance
35
+ end
36
+
32
37
  def _operation_done(no_exit = false)
33
38
  no_exit = false if no_exit.nil?
34
39
  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
@@ -75,8 +75,8 @@ module Gity
75
75
  en = GitLogParser.new(logs)
76
76
  _prmt.puts _fmt "Last 3 last commit : "
77
77
  en.entries.each do |e|
78
- _prmt.puts _fmt "#{e.commit_by}\n #{e.timestamp}\n #{e.commit_notes}"
79
- _prmt.puts _fmt "**** ****"
78
+ _prmt.puts _fmt "#{e.commit_by} @ #{e.timestamp}\n\n #{e.commit_notes}"
79
+ _prmt.puts _fmt "\n**** ****"
80
80
  end
81
81
  _prmt.puts
82
82
  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.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
@@ -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