gpr 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -98
- data/gpr.gemspec +0 -3
- data/lib/gpr/main.rb +0 -5
- data/lib/gpr/version.rb +1 -1
- metadata +2 -53
- data/lib/gpr/actions/contrib.rb +0 -14
- data/lib/gpr/actions/search.rb +0 -52
- data/lib/gpr/commands/contrib.rb +0 -51
- data/lib/gpr/commands/fetch.rb +0 -35
- data/lib/gpr/commands/search.rb +0 -60
- data/lib/gpr/commands/select.rb +0 -17
- data/lib/gpr/commands/status.rb +0 -38
- data/lib/gpr/git_helper.rb +0 -64
- data/zsh/gpr.zsh +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 181c099a71a4666961a12dfd1c559b07474aeef6
|
4
|
+
data.tar.gz: ba1d71e33a3c878c7aef476b0d32e827e60c0c95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f03d43703e429f2578aedca31c5f1c35690cc088364e7977eb1442c8deceab7e5155575deb66b4bde74f616108474510b9f2488da20962212632603303bd197a
|
7
|
+
data.tar.gz: b67c9620dda2bac8bb686dcd83e794b63bdc0d37a28cd7071fe74907b74276ee991e9748d198909e43ddf64735543c00d81dc2d52bcaf438418054adb6f8243e
|
data/README.md
CHANGED
@@ -49,82 +49,6 @@ Options:
|
|
49
49
|
Show all registered repositories
|
50
50
|
```
|
51
51
|
|
52
|
-
### Select a repository using the interactive interface
|
53
|
-
|
54
|
-
```sh
|
55
|
-
$ gpr select
|
56
|
-
```
|
57
|
-
|
58
|
-
Possible use as this.
|
59
|
-
|
60
|
-
![select](http://kaihar4.com/images/github.com/kaihar4/gpr/select.gif)
|
61
|
-
|
62
|
-
Other benefits is [here](#convenient-aliases).
|
63
|
-
|
64
|
-
### Show your contributions of registered repositories
|
65
|
-
|
66
|
-
Display in graph format.
|
67
|
-
|
68
|
-
```sh
|
69
|
-
$ gpr contrib
|
70
|
-
```
|
71
|
-
|
72
|
-
![contrib](http://kaihar4.com/images/github.com/kaihar4/gpr/contrib.png)
|
73
|
-
|
74
|
-
### Show the status of all registered repositories
|
75
|
-
|
76
|
-
You can check the status of the registered repositories at a glance.
|
77
|
-
|
78
|
-
```sh
|
79
|
-
$ gpr status
|
80
|
-
```
|
81
|
-
|
82
|
-
![status](http://kaihar4.com/images/github.com/kaihar4/gpr/status.png)
|
83
|
-
|
84
|
-
### Search the specified keyword in registered repositories
|
85
|
-
|
86
|
-
Show a list of the files that the specified keyword is included.
|
87
|
-
|
88
|
-
```
|
89
|
-
Usage:
|
90
|
-
gpr search
|
91
|
-
|
92
|
-
Options:
|
93
|
-
-f, [--file=FILE] # Filter by filename
|
94
|
-
-h, [--host=HOST] # Filter by host
|
95
|
-
-r, [--repository=REPOSITORY] # Filter by repository
|
96
|
-
|
97
|
-
Search the specified keyword in registered repositories
|
98
|
-
```
|
99
|
-
|
100
|
-
![search](http://kaihar4.com/images/github.com/kaihar4/gpr/search.png)
|
101
|
-
|
102
|
-
### Update the database to be used for search
|
103
|
-
|
104
|
-
```sh
|
105
|
-
$ gpr update
|
106
|
-
```
|
107
|
-
|
108
|
-
### Fetch all registered repositories
|
109
|
-
|
110
|
-
```sh
|
111
|
-
# e.g. gpr fetch origin
|
112
|
-
$ gpr fetch <remote repository>
|
113
|
-
```
|
114
|
-
|
115
|
-
Also possible to specify the branch.
|
116
|
-
|
117
|
-
```sh
|
118
|
-
# e.g. gpr fetch origin master
|
119
|
-
$ gpr fetch <remote repository> <branch>
|
120
|
-
```
|
121
|
-
|
122
|
-
If you run for short, it means `gpr fetch origin`.
|
123
|
-
|
124
|
-
```sh
|
125
|
-
$ gpr fetch
|
126
|
-
```
|
127
|
-
|
128
52
|
## Configuration
|
129
53
|
|
130
54
|
### Change the directory to be cloned
|
@@ -132,25 +56,3 @@ $ gpr fetch
|
|
132
56
|
```sh
|
133
57
|
$ export GPR_ROOT=$HOME/develop
|
134
58
|
```
|
135
|
-
|
136
|
-
### Install the zsh completion
|
137
|
-
|
138
|
-
```sh
|
139
|
-
$ gpr get https://github.com/kaihar4/gpr.git
|
140
|
-
$ cd $HOME/.gpr/github.com/kaihar4/gpr
|
141
|
-
$ rake zsh:install
|
142
|
-
$ source ~/.zshrc
|
143
|
-
```
|
144
|
-
|
145
|
-
### Convenient aliases
|
146
|
-
|
147
|
-
```sh
|
148
|
-
# Change Directory to a directory that you specify
|
149
|
-
alias gcd='cd $(gpr select)'
|
150
|
-
# Remove a directory that you specify
|
151
|
-
alias grm='rm -rf $(gpr select)'
|
152
|
-
|
153
|
-
# And more...
|
154
|
-
alias gcontrib='gpr contrib $(gpr select)'
|
155
|
-
alias gfetch='gpr fetch $(gpr select)'
|
156
|
-
```
|
data/gpr.gemspec
CHANGED
@@ -17,10 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
19
|
spec.add_dependency 'thor'
|
20
|
-
spec.add_dependency 'rroonga'
|
21
20
|
spec.add_dependency 'safe_colorize'
|
22
|
-
spec.add_dependency 'ifilter'
|
23
|
-
spec.add_dependency 'utils_drawer'
|
24
21
|
|
25
22
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
26
23
|
spec.add_development_dependency 'rake'
|
data/lib/gpr/main.rb
CHANGED
@@ -4,11 +4,6 @@ require 'gpr/action'
|
|
4
4
|
require 'gpr/commands/base'
|
5
5
|
require 'gpr/commands/get'
|
6
6
|
require 'gpr/commands/list'
|
7
|
-
require 'gpr/commands/select'
|
8
|
-
require 'gpr/commands/search'
|
9
|
-
require 'gpr/commands/status'
|
10
|
-
require 'gpr/commands/contrib'
|
11
|
-
require 'gpr/commands/fetch'
|
12
7
|
require 'gpr/commands/version'
|
13
8
|
|
14
9
|
Bundler.require
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaihar4
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rroonga
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: safe_colorize
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,34 +38,6 @@ dependencies:
|
|
52
38
|
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: ifilter
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: utils_drawer
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
41
|
- !ruby/object:Gem::Dependency
|
84
42
|
name: bundler
|
85
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,21 +83,12 @@ files:
|
|
125
83
|
- gpr.gemspec
|
126
84
|
- lib/gpr.rb
|
127
85
|
- lib/gpr/action.rb
|
128
|
-
- lib/gpr/actions/contrib.rb
|
129
|
-
- lib/gpr/actions/search.rb
|
130
86
|
- lib/gpr/commands/base.rb
|
131
|
-
- lib/gpr/commands/contrib.rb
|
132
|
-
- lib/gpr/commands/fetch.rb
|
133
87
|
- lib/gpr/commands/get.rb
|
134
88
|
- lib/gpr/commands/list.rb
|
135
|
-
- lib/gpr/commands/search.rb
|
136
|
-
- lib/gpr/commands/select.rb
|
137
|
-
- lib/gpr/commands/status.rb
|
138
89
|
- lib/gpr/commands/version.rb
|
139
|
-
- lib/gpr/git_helper.rb
|
140
90
|
- lib/gpr/main.rb
|
141
91
|
- lib/gpr/version.rb
|
142
|
-
- zsh/gpr.zsh
|
143
92
|
homepage: https://github.com/kaihar4/gpr
|
144
93
|
licenses:
|
145
94
|
- MIT
|
data/lib/gpr/actions/contrib.rb
DELETED
data/lib/gpr/actions/search.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
require 'groonga'
|
4
|
-
|
5
|
-
require 'gpr/git_helper'
|
6
|
-
|
7
|
-
module Gpr
|
8
|
-
module Actions
|
9
|
-
module Search
|
10
|
-
DB_PATH = "#{::Gpr::APP_PATH}/.database"
|
11
|
-
|
12
|
-
def initialize_groonga
|
13
|
-
if FileTest.exist?("#{DB_PATH}/gpr.db")
|
14
|
-
Groonga::Database.open("#{DB_PATH}/gpr.db")
|
15
|
-
else
|
16
|
-
FileUtils.mkdir_p(DB_PATH)
|
17
|
-
Groonga::Context.default_options = { encoding: :utf8 }
|
18
|
-
Groonga::Database.create(path: "#{DB_PATH}/gpr.db")
|
19
|
-
Groonga::Schema.create_table('Files', type: :patricia_trie) do |t|
|
20
|
-
t.text('filename')
|
21
|
-
t.text('body')
|
22
|
-
t.text('host')
|
23
|
-
t.text('repository')
|
24
|
-
end
|
25
|
-
Groonga::Schema.create_table(
|
26
|
-
'Terms',
|
27
|
-
type: :patricia_trie,
|
28
|
-
normalizer: :NormalizerAuto,
|
29
|
-
default_tokenizer: 'TokenBigramSplitSymbolAlpha'
|
30
|
-
) do |t|
|
31
|
-
t.index('Files.body')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_file(path)
|
37
|
-
repo_info = parse_repository(path)
|
38
|
-
|
39
|
-
GitHelper.ls_files(path).each do |file|
|
40
|
-
next unless FileTest.file?(file)
|
41
|
-
Groonga['Files'].add(
|
42
|
-
File.expand_path(file),
|
43
|
-
filename: File.basename(file),
|
44
|
-
body: File.open(file).read,
|
45
|
-
host: repo_info[:host],
|
46
|
-
repository: repo_info[:repository]
|
47
|
-
)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/lib/gpr/commands/contrib.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'utils_drawer'
|
2
|
-
|
3
|
-
require 'gpr/git_helper'
|
4
|
-
require 'gpr/actions/contrib'
|
5
|
-
|
6
|
-
module Gpr
|
7
|
-
module Commands
|
8
|
-
class Contrib < Base
|
9
|
-
def initialize(thor)
|
10
|
-
thor.class_eval do
|
11
|
-
include UtilsDrawer
|
12
|
-
include ::Gpr::Actions::Contrib
|
13
|
-
|
14
|
-
desc 'contrib', 'Show your contributions of registered repositories'
|
15
|
-
def contrib(path = nil)
|
16
|
-
user = detect_git_user || ENV['USER']
|
17
|
-
|
18
|
-
if path.nil?
|
19
|
-
repositories = repository_list
|
20
|
-
dates = repositories.each_with_object([]) { |repository, ary|
|
21
|
-
ary << GitHelper.log_by_date(repository, user)
|
22
|
-
}.flatten!
|
23
|
-
else
|
24
|
-
dates = GitHelper.log_by_date(path, user)
|
25
|
-
end
|
26
|
-
|
27
|
-
first_date = Time.parse(dates.sort.first)
|
28
|
-
diff = ((Time.now - first_date).to_i / 86400) + 1
|
29
|
-
|
30
|
-
# Initialize a hash
|
31
|
-
commit_counts = diff.times.each_with_object({}) do |index, hash|
|
32
|
-
date = Time.at(first_date + (86400 * index)).strftime('%Y-%m-%d')
|
33
|
-
hash[date] = 0
|
34
|
-
end
|
35
|
-
|
36
|
-
# Count commits
|
37
|
-
dates.each do |date|
|
38
|
-
commit_counts[date] += 1 if commit_counts[date]
|
39
|
-
end
|
40
|
-
|
41
|
-
graph do
|
42
|
-
commit_counts.sort.each do |date, value|
|
43
|
-
data(date, value)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/lib/gpr/commands/fetch.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'safe_colorize'
|
2
|
-
|
3
|
-
require 'gpr/git_helper'
|
4
|
-
|
5
|
-
module Gpr
|
6
|
-
module Commands
|
7
|
-
class Fetch < Base
|
8
|
-
using SafeColorize
|
9
|
-
|
10
|
-
def initialize(thor)
|
11
|
-
thor.class_eval do
|
12
|
-
desc 'fetch', 'Fetch the registered repositories'
|
13
|
-
def fetch(remote = 'origin', branch = nil, path = nil)
|
14
|
-
if path.nil?
|
15
|
-
repositories = repository_list
|
16
|
-
repositories.each do |repository|
|
17
|
-
repo_info = parse_repository(repository)
|
18
|
-
|
19
|
-
puts "#{repo_info[:host].color(:yellow)} - #{repo_info[:repository].color(:blue)}"
|
20
|
-
|
21
|
-
GitHelper.fetch(repository, remote, branch)
|
22
|
-
end
|
23
|
-
else
|
24
|
-
repo_info = parse_repository(path)
|
25
|
-
|
26
|
-
puts "#{repo_info[:host].color(:yellow)} - #{repo_info[:repository].color(:blue)}"
|
27
|
-
|
28
|
-
GitHelper.fetch(path, remote, branch)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/gpr/commands/search.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'groonga'
|
2
|
-
require 'safe_colorize'
|
3
|
-
|
4
|
-
require 'gpr/actions/search'
|
5
|
-
|
6
|
-
module Gpr
|
7
|
-
module Commands
|
8
|
-
class Search < Base
|
9
|
-
using SafeColorize
|
10
|
-
include ::Gpr::Actions::Search
|
11
|
-
|
12
|
-
def initialize(thor)
|
13
|
-
initialize_groonga
|
14
|
-
|
15
|
-
thor.class_eval do
|
16
|
-
include ::Gpr::Actions::Search
|
17
|
-
|
18
|
-
desc 'search', 'Search the specified keyword in registered repositories'
|
19
|
-
option :file, type: :string, aliases: '-f', desc: 'Filter by filename'
|
20
|
-
option :host, type: :string, aliases: '-h', desc: 'Filter by host'
|
21
|
-
option :repository, type: :string, aliases: '-r', desc: 'Filter by repository'
|
22
|
-
def search(string)
|
23
|
-
result = Groonga['Files'].select do |record|
|
24
|
-
record.body =~ string
|
25
|
-
end
|
26
|
-
|
27
|
-
result.each do |record|
|
28
|
-
next unless FileTest.exist?(record._key)
|
29
|
-
|
30
|
-
next if options[:file] && !(record.filename =~ /#{options[:file]}/)
|
31
|
-
next if options[:host] && !(record.host == options[:host])
|
32
|
-
next if options[:repository] && !(record.repository == options[:repository])
|
33
|
-
|
34
|
-
relative_path = record._key.sub(/#{::Gpr::APP_PATH}\/#{record.host}\/#{record.repository}\//, '')
|
35
|
-
puts "#{record.host.color(:yellow)} - #{record.repository.color(:blue)} : #{relative_path.color(:red)}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
desc 'update', 'Update the database to be used for search'
|
40
|
-
def update
|
41
|
-
puts 'Updating...'
|
42
|
-
|
43
|
-
Groonga['Files'].truncate
|
44
|
-
|
45
|
-
# Remove unregistered directories
|
46
|
-
Dir.glob("#{::Gpr::APP_PATH}/*/*").each do |path|
|
47
|
-
# Unregistered directories returns [".", ".."].
|
48
|
-
Dir.rmdir(path) if Dir.entries(path).size == 2
|
49
|
-
end
|
50
|
-
|
51
|
-
repositories = repository_list
|
52
|
-
repositories.each do |repository|
|
53
|
-
add_file(repository)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/lib/gpr/commands/select.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'ifilter'
|
2
|
-
|
3
|
-
module Gpr
|
4
|
-
module Commands
|
5
|
-
class Select < Base
|
6
|
-
def initialize(thor)
|
7
|
-
thor.class_eval do
|
8
|
-
desc 'select', 'Select a repository using the interactive interface'
|
9
|
-
def select
|
10
|
-
repositories = repository_list
|
11
|
-
puts Ifilter.filtering(repositories)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/gpr/commands/status.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'utils_drawer'
|
2
|
-
require 'safe_colorize'
|
3
|
-
|
4
|
-
require 'gpr/git_helper'
|
5
|
-
|
6
|
-
module Gpr
|
7
|
-
module Commands
|
8
|
-
class Status < Base
|
9
|
-
using SafeColorize
|
10
|
-
|
11
|
-
def initialize(thor)
|
12
|
-
thor.class_eval do
|
13
|
-
include UtilsDrawer
|
14
|
-
|
15
|
-
desc 'status', 'Show the status of all registered repositories'
|
16
|
-
def status
|
17
|
-
repositories = repository_list
|
18
|
-
table do
|
19
|
-
row do
|
20
|
-
column('REPOSITORY NAME'.style(:bold), 25)
|
21
|
-
column('BRANCH STATUS'.style(:bold), 45)
|
22
|
-
column('DIRECTORY STATUS'.style(:bold), 25)
|
23
|
-
end
|
24
|
-
repositories.each do |repository|
|
25
|
-
status = GitHelper.status(repository)
|
26
|
-
row do
|
27
|
-
column(repository.match(/.+\/(?<repository>.+\/.+)/)[:repository])
|
28
|
-
column(status[:branch])
|
29
|
-
column(status[:directory])
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/lib/gpr/git_helper.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'safe_colorize'
|
2
|
-
|
3
|
-
module Gpr
|
4
|
-
module GitHelper
|
5
|
-
using SafeColorize
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def ls_files(path)
|
9
|
-
Dir.chdir(path)
|
10
|
-
`git ls-files`.split("\n")
|
11
|
-
end
|
12
|
-
|
13
|
-
def status(path)
|
14
|
-
Dir.chdir(path)
|
15
|
-
result = {}
|
16
|
-
git_status = `git status -sb`.split("\n")
|
17
|
-
branch_name = git_status.shift.match(/## (?<branch>.+)/)[:branch]
|
18
|
-
unstaged_changes = []
|
19
|
-
untracked_files = []
|
20
|
-
|
21
|
-
git_status.each do |file|
|
22
|
-
if match_object = file.match(/^\sM (.+)$/)
|
23
|
-
unstaged_changes << match_object[1]
|
24
|
-
elsif match_object = file.match(/^\?\? (.+)$/)
|
25
|
-
untracked_files << match_object[1]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Means no branch || ahead || behind
|
30
|
-
if branch_name =~ /HEAD|\[.+\]/
|
31
|
-
result[:branch] = branch_name.color(:red)
|
32
|
-
else
|
33
|
-
result[:branch] = branch_name.color(:green)
|
34
|
-
end
|
35
|
-
|
36
|
-
if unstaged_changes.empty? && untracked_files.empty?
|
37
|
-
result[:directory] = 'Working directory clean'.color(:green)
|
38
|
-
else
|
39
|
-
result[:directory] = "Modified[#{unstaged_changes.size}] ??[#{untracked_files.size}]".color(:red)
|
40
|
-
end
|
41
|
-
|
42
|
-
result
|
43
|
-
end
|
44
|
-
|
45
|
-
def log_by_date(path, user = nil)
|
46
|
-
Dir.chdir(path)
|
47
|
-
if user.nil?
|
48
|
-
`git log --date=short --pretty=format:"%cd"`.split("\n")
|
49
|
-
else
|
50
|
-
`git log --author=#{user} --date=short --pretty=format:"%cd"`.split("\n")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def fetch(path, remote, branch)
|
55
|
-
Dir.chdir(path)
|
56
|
-
if branch.nil?
|
57
|
-
`git fetch #{remote}`
|
58
|
-
else
|
59
|
-
`git fetch #{remote} #{branch}`
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/zsh/gpr.zsh
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
function _gpr () {
|
2
|
-
local context curcontext=$curcontext state line
|
3
|
-
declare -A opt_args
|
4
|
-
local ret=1
|
5
|
-
|
6
|
-
_arguments -C \
|
7
|
-
'1: :__gpr_cmds' \
|
8
|
-
'*:: :->args' \
|
9
|
-
&& ret=0
|
10
|
-
|
11
|
-
case $state in
|
12
|
-
(args)
|
13
|
-
case $words[1] in
|
14
|
-
(get)
|
15
|
-
;;
|
16
|
-
(help)
|
17
|
-
__gpr_cmds \
|
18
|
-
&& ret=0
|
19
|
-
;;
|
20
|
-
(list)
|
21
|
-
_arguments -C \
|
22
|
-
'--paths[Show the paths of all registered repositories]' \
|
23
|
-
'(-)*:: :->null_state' \
|
24
|
-
&& ret=0
|
25
|
-
;;
|
26
|
-
(select)
|
27
|
-
;;
|
28
|
-
(contrib)
|
29
|
-
;;
|
30
|
-
(search)
|
31
|
-
_arguments -C \
|
32
|
-
'-f[Filter by filename]' \
|
33
|
-
'-h[Filter by host]' \
|
34
|
-
'-r[Filter by repository]' \
|
35
|
-
'(-)*:: :->null_state' \
|
36
|
-
&& ret=0
|
37
|
-
;;
|
38
|
-
(update)
|
39
|
-
;;
|
40
|
-
(fetch)
|
41
|
-
;;
|
42
|
-
(status)
|
43
|
-
;;
|
44
|
-
(version)
|
45
|
-
;;
|
46
|
-
esac
|
47
|
-
;;
|
48
|
-
esac
|
49
|
-
|
50
|
-
return ret
|
51
|
-
}
|
52
|
-
|
53
|
-
__gpr_cmds () {
|
54
|
-
local -a _c
|
55
|
-
_c=(
|
56
|
-
'get:Get a repository'
|
57
|
-
'help:Describe available commands or one specific command'
|
58
|
-
'list:Show all registered repositories'
|
59
|
-
'select:Select a repository using the interactive interface'
|
60
|
-
'contrib:Show your contributions of registered repositories'
|
61
|
-
'search:Search the specified keyword in registered repositories'
|
62
|
-
'update:Update the database to be used for search'
|
63
|
-
'fetch:Fetch the registered repositories'
|
64
|
-
'status:Show the status of all registered repositories'
|
65
|
-
'version:Display installed gpr version'
|
66
|
-
)
|
67
|
-
|
68
|
-
_describe -t commands Commands _c
|
69
|
-
}
|
70
|
-
compdef _gpr gpr
|