gpr 0.1.2 → 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
  SHA1:
3
- metadata.gz: 2c11926b160dca631188153c62153510901e3bef
4
- data.tar.gz: 529750cb9b97d1317ce1642c567ab9bd45bb1706
3
+ metadata.gz: 6fc828306cf6fcbd57901691545268d4fce5fac8
4
+ data.tar.gz: c07bf80b3194da4ed975ab34d6713cc1a6b2c54d
5
5
  SHA512:
6
- metadata.gz: b72525f504cfd32a9b2f91d8ede053c6fb5a212552f668ffec575fc76c13a12fa5af8a5445e11d99935ca7059cba34838987f1beb6576860a743b80c6eb95bfa
7
- data.tar.gz: b4ead424e95bc6d5d4659f0e8bdf45436f1bf9851dd27ec755aa94bce08d4332616965e060d300b1bc67537abb380393a867656f89df1b0711ccf485eda186a8
6
+ metadata.gz: f731f0de4b5dec48f3778c8da6d80edfa9aa7de5ba608616a5ec8d8a2df991e0672915448250767a001405ce5a5df203c8f082ab31870b5e45fd21dee5acd4d6
7
+ data.tar.gz: e09dd812a64e122c9fd6fbb3876bb4bf6f1a98ee2665acdd61f798e2b8af275074d404af44fd4b999e4278078b7e5edb96f4d0bbc68f702f474b9819b7c49df1
data/lib/gpr/cli.rb CHANGED
@@ -137,7 +137,8 @@ module Gpr
137
137
  puts 'Processing...'
138
138
 
139
139
  Dir.glob("#{APP_PATH}/*/*").each do |path|
140
- Dir.rmdir(path) if Dir.entries(path).join == '...'
140
+ # Unregistered directories returns [".", ".."].
141
+ Dir.rmdir(path) if Dir.entries(path).size == 2
141
142
  end
142
143
  end
143
144
 
@@ -26,34 +26,32 @@ module Gpr
26
26
  def status(path)
27
27
  Dir.chdir(path)
28
28
  result = {}
29
- git_status = `git status`
30
- branch_name = git_status.match(/(On branch .+)/)[1]
31
- branch_status = `git status -sb`.split("\n")[0].match(/## (.+)/)[1]
29
+ git_status = `git status -sb`.split("\n")
30
+ branch_name = git_status.shift.match(/## (.+)/)[1]
31
+ unstaged_changes = []
32
+ untracked_files = []
32
33
 
33
- # Means ahead || behind
34
- if branch_status =~ /\[.+\]/
35
- result[:branch] = branch_status.color(:red)
36
-
37
- elsif git_status =~ /up-to-date with 'origin\/master'/
38
- result[:branch] = (branch_name + " {origin/master}").color(:green)
34
+ git_status.each do |file|
35
+ if match_object = file.match(/^\sM (.+)$/)
36
+ unstaged_changes << match_object[1]
37
+ elsif match_object = file.match(/^\?\? (.+)$/)
38
+ untracked_files << match_object[1]
39
+ end
40
+ end
39
41
 
42
+ # Means no branch || ahead || behind
43
+ if branch_name =~ /HEAD|\[.+\]/
44
+ result[:branch] = branch_name.color(:red)
40
45
  else
41
46
  result[:branch] = branch_name.color(:green)
42
47
  end
43
48
 
44
- case git_status
45
- when /nothing to commit, working directory clean/
49
+ if unstaged_changes.empty? && untracked_files.empty?
46
50
  result[:directory] = 'Working directory clean'.color(:green)
47
-
48
- when /Changes to be committed:/
49
- result[:directory] = 'Exist staged changes'.color(:red)
50
-
51
- when /Changes not staged for commit:/
52
- result[:directory] = 'Exist unstaged changes'.color(:red)
53
-
54
- when /Untracked files:/
55
- result[:directory] = 'Exist untracked files'.color(:red)
51
+ else
52
+ result[:directory] = "Modified[#{unstaged_changes.size}] ??[#{untracked_files.size}]".color(:red)
56
53
  end
54
+
57
55
  result
58
56
  end
59
57
 
data/lib/gpr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gpr
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaihar4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2015-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor