gpr 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 +4 -4
- data/README.md +6 -0
- data/Rakefile +23 -3
- data/lib/gpr/cli.rb +12 -2
- data/lib/gpr/git_helper.rb +7 -5
- data/lib/gpr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c11926b160dca631188153c62153510901e3bef
|
4
|
+
data.tar.gz: 529750cb9b97d1317ce1642c567ab9bd45bb1706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b72525f504cfd32a9b2f91d8ede053c6fb5a212552f668ffec575fc76c13a12fa5af8a5445e11d99935ca7059cba34838987f1beb6576860a743b80c6eb95bfa
|
7
|
+
data.tar.gz: b4ead424e95bc6d5d4659f0e8bdf45436f1bf9851dd27ec755aa94bce08d4332616965e060d300b1bc67537abb380393a867656f89df1b0711ccf485eda186a8
|
data/README.md
CHANGED
@@ -115,6 +115,12 @@ Search the specified keyword in registered repositories
|
|
115
115
|
|
116
116
|

|
117
117
|
|
118
|
+
### Remove the unregistered directories
|
119
|
+
|
120
|
+
```sh
|
121
|
+
$ gpr clean
|
122
|
+
```
|
123
|
+
|
118
124
|
### Update the database to be used for search
|
119
125
|
|
120
126
|
```sh
|
data/Rakefile
CHANGED
@@ -1,17 +1,37 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
|
3
3
|
namespace :zsh do
|
4
|
+
COMPLETION_PATH = "source #{File.dirname(__FILE__)}/zsh/gpr.zsh"
|
5
|
+
|
4
6
|
desc 'Install the zsh completion'
|
5
7
|
task :install do
|
6
8
|
if ENV['SHELL'].include?('zsh')
|
7
9
|
File.open("#{ENV['HOME']}/.zshrc", 'a+') do |file|
|
8
|
-
|
10
|
+
file.flock(File::LOCK_EX)
|
9
11
|
|
10
|
-
|
12
|
+
body = file.read
|
13
|
+
unless body.include?(COMPLETION_PATH)
|
14
|
+
file.puts COMPLETION_PATH
|
15
|
+
puts "Done.\nPlease execute 'source ~/.zshrc'."
|
16
|
+
end
|
11
17
|
end
|
12
|
-
puts 'Done.'
|
13
18
|
else
|
14
19
|
puts 'Please change default shell to zsh.'
|
15
20
|
end
|
16
21
|
end
|
22
|
+
|
23
|
+
desc 'Clean the zsh completion'
|
24
|
+
task :clean do
|
25
|
+
File.open("#{ENV['HOME']}/.zshrc", 'r+') do |file|
|
26
|
+
file.flock(File::LOCK_EX)
|
27
|
+
|
28
|
+
body = file.read
|
29
|
+
if body.include?(COMPLETION_PATH)
|
30
|
+
file.rewind
|
31
|
+
file.write(body.gsub(/#{COMPLETION_PATH}\n/, ''))
|
32
|
+
file.truncate(file.tell)
|
33
|
+
puts "Done.\nPlease execute 'source ~/.zshrc'."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
17
37
|
end
|
data/lib/gpr/cli.rb
CHANGED
@@ -132,6 +132,15 @@ module Gpr
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
desc 'clean', 'Remove the unregistered directories'
|
136
|
+
def clean
|
137
|
+
puts 'Processing...'
|
138
|
+
|
139
|
+
Dir.glob("#{APP_PATH}/*/*").each do |path|
|
140
|
+
Dir.rmdir(path) if Dir.entries(path).join == '...'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
135
144
|
desc 'update', 'Update the database to be used for search'
|
136
145
|
def update
|
137
146
|
puts 'Updating...'
|
@@ -174,10 +183,11 @@ module Gpr
|
|
174
183
|
column('DIRECTORY STATUS'.style(:bold), 25)
|
175
184
|
end
|
176
185
|
repositories.each do |repository|
|
186
|
+
status = GitHelper.status(repository)
|
177
187
|
row do
|
178
188
|
column(repository.match(/.+\/(.+\/.+)/)[1])
|
179
|
-
column(
|
180
|
-
column(
|
189
|
+
column(status[:branch])
|
190
|
+
column(status[:directory])
|
181
191
|
end
|
182
192
|
end
|
183
193
|
end
|
data/lib/gpr/git_helper.rb
CHANGED
@@ -27,16 +27,18 @@ module Gpr
|
|
27
27
|
Dir.chdir(path)
|
28
28
|
result = {}
|
29
29
|
git_status = `git status`
|
30
|
+
branch_name = git_status.match(/(On branch .+)/)[1]
|
30
31
|
branch_status = `git status -sb`.split("\n")[0].match(/## (.+)/)[1]
|
31
32
|
|
32
|
-
case branch_status
|
33
33
|
# Means ahead || behind
|
34
|
-
|
34
|
+
if branch_status =~ /\[.+\]/
|
35
35
|
result[:branch] = branch_status.color(:red)
|
36
|
-
|
37
|
-
|
36
|
+
|
37
|
+
elsif git_status =~ /up-to-date with 'origin\/master'/
|
38
|
+
result[:branch] = (branch_name + " {origin/master}").color(:green)
|
39
|
+
|
38
40
|
else
|
39
|
-
result[:branch] =
|
41
|
+
result[:branch] = branch_name.color(:green)
|
40
42
|
end
|
41
43
|
|
42
44
|
case git_status
|
data/lib/gpr/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.2
|
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
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|