git_explorer 0.2.1 → 0.2.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
  SHA1:
3
- metadata.gz: 98edb707164d29c0dbffbece848ed603f2f60f33
4
- data.tar.gz: b480b70d00cf0e3d4ee4f3d99cae732a49784c6b
3
+ metadata.gz: cb8027b449b71edf38c5951620f15b71c76fb8c6
4
+ data.tar.gz: 1698c8b3eecaa2efceace6f8f8501c264401e935
5
5
  SHA512:
6
- metadata.gz: 538f7a0065fb79ec208dd1dd5c3b4fb07c249ec791c0162ccfdc81098074c1b6c8ebc443fdf71ea49fedb4eeef02e59524cf8766a0741151a5e1cab16329a509
7
- data.tar.gz: 5ff1ee5a3d94b6ea6e893c2e61cb669f7c9d8b8560cbef0499dd06387f9ffd2f99152467bae1f599781d741a415b9a7d7c1d909202bf9b76ba88d976986458b4
6
+ metadata.gz: f16b35903320168e99b70d049b20d752188d0b781585c1a2303441591a202190a89dfb5008e8484594d38b6a30d674d29a8fd3255b6026811c2e962b15a34e59
7
+ data.tar.gz: f25a4e3848044aac14c37a73a901491fd3493ff8c4f6cbfab4a7a6b16d88083092afd2d9febc0a9f5d1086def059af7801b0a1970eb0e2d815f1f42c70556ba7
data/README.md CHANGED
@@ -21,7 +21,7 @@ Linux:
21
21
 
22
22
  Start explore with:
23
23
  ```bash
24
- ~$ git-explore <root_path>
24
+ ~$ git-explorer explore <root_path>
25
25
  ```
26
26
 
27
27
  All your git repositories from <root_path> will be scanned and the output will be similar to:
@@ -43,7 +43,7 @@ In a try to add a feature to my old ls command, I've created the **light explore
43
43
  ![light demo](light_demo.gif)
44
44
 
45
45
  ```bash
46
- ~$ git explore --light
46
+ ~$ git-explorer explore --light
47
47
  ```
48
48
 
49
49
  The output will decorate any directory that is also a git repository:
@@ -11,8 +11,10 @@ module GitExplorer
11
11
  -> (status_output) {
12
12
  project_name = status_output[/^(?<project_name>.*)$/, "project_name"]
13
13
  branch = status_output[/On branch\s(?<branch>.*)/, "branch"]
14
- status = :up_to_date unless status_output[/not staged/]
15
- status = :not_staged if status_output[/not staged/]
14
+ status = []
15
+ status << :up_to_date if status_output[/up-to-date/]
16
+ status << :not_staged if status_output[/not staged/]
17
+ status << :to_be_committed if status_output[/to be committed/]
16
18
  files = status_output.scan(/modified: \s*(.*)$/).flatten
17
19
  GitStatus.new(status, project_name, branch, files)
18
20
  }
@@ -21,8 +23,10 @@ module GitExplorer
21
23
  def extract_light_status(status_output)
22
24
  project_name = status_output[/^(?<project_name>.*)$/, "project_name"]
23
25
  branch = status_output[/On branch\s(?<branch>.*)/, "branch"]
24
- status = :up_to_date unless status_output[/not staged/]
25
- status = :not_staged if status_output[/not staged/]
26
+ status = []
27
+ status << :up_to_date if status_output[/up-to-date/]
28
+ status << :not_staged if status_output[/not staged/]
29
+ status << :to_be_committed if status_output[/to be committed/]
26
30
  files = status_output.scan(/modified: \s*(.*)$/).flatten
27
31
  GitStatus.new(status, project_name, branch, files)
28
32
  end
@@ -47,6 +51,24 @@ module GitExplorer
47
51
  run("basename `git -C #{path} rev-parse --show-toplevel`; git -C #{path} status", config={:capture=>true, :verbose=>false})
48
52
  end
49
53
 
54
+ def translate_status(statuses)
55
+ possible_status = {
56
+ to_be_committed: '✚',
57
+ up_to_date: '✔',
58
+ not_staged: '●',
59
+ conflict: '✖'
60
+ }
61
+
62
+ statuses.inject('') {|string, status| string = string + possible_status[status].to_s}
63
+ end
64
+
65
+ def translate_color(statuses)
66
+ return :green if statuses == [:up_to_date]
67
+ return :red if statuses == [:conflict]
68
+
69
+ :cyan
70
+ end
71
+
50
72
  class Explorer < Thor
51
73
  include Thor::Actions
52
74
  include GitExplorer
@@ -65,10 +87,9 @@ module GitExplorer
65
87
  .map{|line| Line.new(line.full_line, '', git_repository?(extract_path(line.full_line, root_dir)))}
66
88
  .map{|line| Line.new(line.full_line, (extract_light_status(git_status(extract_path(line.full_line, root_dir))) if line.git_repository == true), line.git_repository)}
67
89
  .map{|line|
68
- say(message="#{line.full_line} ")
69
- say(message="#{'[' + line.state.branch + ']'} ", color=(:red)) if line.git_repository == true and line.state.status != :up_to_date
70
- say(message="#{'[' + line.state.branch + ']'} ✔ ", color=(:green)) if line.git_repository == true and line.state.status == :up_to_date
71
- say(message="\n")
90
+ say(message="#{line.full_line} ")
91
+ say(message="#{'[' + line.state.branch + ']'} #{translate_status(line.state.status)} ", color=(translate_color(line.state.status))) if line.git_repository
92
+ say(message="\n")
72
93
  }
73
94
  else
74
95
  run("find #{root_dir} -type d -name .git", config={:capture=>true, :verbose=>false})
@@ -79,6 +100,5 @@ module GitExplorer
79
100
  .map{|status| say(message="#{status.project_name} is #{status.status} on branch #{status.branch}\n#{status.files.map{|f| "\t#{f}\n"}.join}", color=(:red if status.status.equal?(:not_staged)))}
80
101
  end
81
102
  end
82
-
83
103
  end
84
104
  end
@@ -1,3 +1,3 @@
1
1
  module GitExplorer
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_explorer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rocha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-08 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler