githelp 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/Makefile +6 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/data/adddelete.rb +10 -0
- data/data/afteradd.rb +16 -0
- data/data/appear.rb +16 -0
- data/data/branch.rb +33 -0
- data/data/cat-file.rb +15 -0
- data/data/change.rb +95 -0
- data/data/checkout.rb +27 -0
- data/data/commit.rb +7 -0
- data/data/freq.rb +13 -0
- data/data/fresh.rb +7 -0
- data/data/grep.rb +8 -0
- data/data/ignore.rb +11 -0
- data/data/log.rb +8 -0
- data/data/ls-files.rb +15 -0
- data/data/mv.rb +7 -0
- data/data/removed.rb +17 -0
- data/data/reset.rb +11 -0
- data/data/rm.rb +8 -0
- data/data/shortlog.rb +13 -0
- data/data/show.rb +7 -0
- data/data/status.rb +11 -0
- data/data/tag.rb +27 -0
- data/data.txt +12 -0
- data/exe/githelp +73 -0
- data/exe/githelp-changed +12 -0
- data/exe/githelp-fileadded +25 -0
- data/exe/githelp-unchanged +11 -0
- data/githelp.gemspec +26 -0
- data/lib/githelp/args.rb +17 -0
- data/lib/githelp/branches.rb +22 -0
- data/lib/githelp/changes.rb +19 -0
- data/lib/githelp/files.rb +23 -0
- data/lib/githelp/glossary.rb +17 -0
- data/lib/githelp/numbers.rb +14 -0
- data/lib/githelp/params.rb +17 -0
- data/lib/githelp/patterns.rb +20 -0
- data/lib/githelp/tags.rb +25 -0
- data/lib/githelp/version.rb +3 -0
- data/lib/githelp.rb +91 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6224d4653f7848cf6b964cfecf7cb9cc2c812831
|
4
|
+
data.tar.gz: 00b553cad0ca0c3e671b3f8179d7a690bf92a299
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45534e1d22236e18abf1da8cd100ea46a359b60176443e2d7ba95445cbec40425a951563b05873f8b67fc23e416c1a7d231b01a0afb5430845dd5b3dd3fc0db8
|
7
|
+
data.tar.gz: 7e82020186ac0e32232e02a3a92067e37e974186bdd02d4d47174e949b509e9ef636ffa142da854df50645c4f0453f746984b245eeb743f1a6ba453316d586e8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Toshiyuki Masui
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Githelp
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/githelp`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'githelp'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install githelp
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/githelp.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/data/adddelete.rb
ADDED
data/data/afteradd.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# 結城氏が欲しいといったもの
|
4
|
+
# https://www.facebook.com/toshiyukimasui/posts/10154167175512498?comment_id=10154167320572498
|
5
|
+
#
|
6
|
+
|
7
|
+
if params.length > 0
|
8
|
+
[
|
9
|
+
[
|
10
|
+
"最初に「(#{params.join('|')})」という文字列を含むコミットをした時から現在までに追加されたファイルはどれとどれ?",
|
11
|
+
'git log --oneline --date=iso-strict --format=\'%cd %s\' | grep #{$1} | tail -1 | awk \'{print $1}\' | xargs githelp-changed '
|
12
|
+
],
|
13
|
+
]
|
14
|
+
else
|
15
|
+
nil
|
16
|
+
end
|
data/data/appear.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
if params.length > 0 && files.length > 0
|
3
|
+
[
|
4
|
+
[
|
5
|
+
"「(#{files.join('|')})」ファイルに「(#{params.join('|')})」という名前が出現したのはいつ?",
|
6
|
+
'git blame #{$1} | grep #{$2}'
|
7
|
+
],
|
8
|
+
[
|
9
|
+
"「(#{params.join('|')})」という名前が「(#{files.join('|')})」ファイルに出現したのはいつ?",
|
10
|
+
'git blame #{$2} | grep #{$1}'
|
11
|
+
]
|
12
|
+
]
|
13
|
+
else
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
data/data/branch.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
[
|
3
|
+
[
|
4
|
+
"ブランチをリストする",
|
5
|
+
"git branch"
|
6
|
+
],
|
7
|
+
[
|
8
|
+
"ブランチのリストを表示する",
|
9
|
+
"git branch"
|
10
|
+
],
|
11
|
+
[
|
12
|
+
"「(#{branches.join('|')})」ブランチを削除する",
|
13
|
+
'git branch -d #{$1}'
|
14
|
+
],
|
15
|
+
[
|
16
|
+
"「(#{params.join('|')})」ブランチを作成する",
|
17
|
+
'git branch #{$1}'
|
18
|
+
],
|
19
|
+
] +
|
20
|
+
if params.length > 0
|
21
|
+
[
|
22
|
+
[
|
23
|
+
"「(#{params.join('|')})」という名前の新しいブランチを作成する",
|
24
|
+
'git branch #{$1}'
|
25
|
+
],
|
26
|
+
[
|
27
|
+
"新しいブランチを「(#{params.join('|')})」という名前で作成する",
|
28
|
+
'git branch #{$1}'
|
29
|
+
]
|
30
|
+
]
|
31
|
+
else
|
32
|
+
[]
|
33
|
+
end
|
data/data/cat-file.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
[
|
3
|
+
[
|
4
|
+
"(#{numbers.join('|')})分前の「(#{files.join('|')})」ファイルを(表示する|見る)",
|
5
|
+
'git cat-file -p "@{#{$1} minutes ago}":#{$2}'
|
6
|
+
],
|
7
|
+
[
|
8
|
+
"(#{numbers.join('|')})時間前の「(#{files.join('|')})」ファイルを(表示する|見る)",
|
9
|
+
'git cat-file -p "@{#{$1} hours ago}":#{$2}'
|
10
|
+
],
|
11
|
+
[
|
12
|
+
"(#{numbers.join('|')})日前の「(#{files.join('|')})」ファイルを(表示する|見る)",
|
13
|
+
'git cat-file -p "@{#{$1} days ago}":#{$2}'
|
14
|
+
],
|
15
|
+
]
|
data/data/change.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
patterns != ['##PATTERN##'] ?
|
4
|
+
[
|
5
|
+
[
|
6
|
+
"「(#{files.join('|')})」ファイルを(#{numbers.join('|')})分前の(もの|バージョン)と比較する",
|
7
|
+
'git diff HEAD "@{#{$2} minutes ago}" #{$1}'
|
8
|
+
],
|
9
|
+
[
|
10
|
+
"「(#{files.join('|')})」ファイルが(#{numbers.join('|')})分前から(変化した|変わった)ところを(表示する|見る)",
|
11
|
+
'git diff HEAD "@{#{$2} minutes ago}" #{$1}'
|
12
|
+
],
|
13
|
+
[
|
14
|
+
"「(#{files.join('|')})」ファイルを(#{numbers.join('|')})時間前の(もの|バージョン)と比較する",
|
15
|
+
'git diff HEAD "@{#{$2} hours ago}" #{$1}'
|
16
|
+
],
|
17
|
+
[
|
18
|
+
"「(#{files.join('|')})」ファイルが(#{numbers.join('|')})時間前から(変化した|変わった)ところを(表示する|見る)",
|
19
|
+
'git diff HEAD "@{#{$2} hours ago}" #{$1}'
|
20
|
+
],
|
21
|
+
[
|
22
|
+
"「(#{files.join('|')})」ファイルを(#{numbers.join('|')})日前の(もの|バージョン)と比較する",
|
23
|
+
'git diff HEAD "@{#{$2} days ago}" #{$1}'
|
24
|
+
],
|
25
|
+
[
|
26
|
+
"「(#{files.join('|')})」ファイルが(#{numbers.join('|')})日前から(変化した|変わった)ところを(表示する|見る)",
|
27
|
+
'git diff HEAD "@{#{$2} days ago}" #{$1}'
|
28
|
+
],
|
29
|
+
[
|
30
|
+
"(#{numbers.join('|')})分前の「(#{files.join('|')})」ファイルと現在の(もの|バージョン)を比較する",
|
31
|
+
'git diff HEAD "@{#{$1} minutes ago}" #{$2}'
|
32
|
+
],
|
33
|
+
[
|
34
|
+
"(#{numbers.join('|')})時間前の「(#{files.join('|')})」ファイルと現在の(もの|バージョン)を比較する",
|
35
|
+
'git diff HEAD "@{#{$1} hours ago}" #{$2}'
|
36
|
+
],
|
37
|
+
[
|
38
|
+
"(#{numbers.join('|')})日前の「(#{files.join('|')})」ファイルと現在の(もの|バージョン)を比較する",
|
39
|
+
'git diff HEAD "@{#{$1} days ago}" #{$2}'
|
40
|
+
],
|
41
|
+
[
|
42
|
+
"(#{numbers.join('|')})分前からの「(#{files.join('|')})」ファイル(の変化|が(変わった|変更された)ところ)を(表示する|見る)",
|
43
|
+
'git diff HEAD "@{#{$1} minutes ago}" #{$2}'
|
44
|
+
],
|
45
|
+
[
|
46
|
+
"(#{numbers.join('|')})時間前からの「(#{files.join('|')})」ファイル(の変化|が(変わった|変更された)ところ)を(表示する|見る)",
|
47
|
+
'git diff HEAD "@{#{$1} hours ago}" #{$2}'
|
48
|
+
],
|
49
|
+
[
|
50
|
+
"(#{numbers.join('|')})日前からの「(#{files.join('|')})」ファイル(の変化|が(変わった|変更された)ところ)を(表示する|見る)",
|
51
|
+
'git diff HEAD "@{#{$1} days ago}" #{$2}'
|
52
|
+
],
|
53
|
+
[
|
54
|
+
"「(#{files.join('|')})」ファイルをひとつ前のコミットと比較する",
|
55
|
+
'git diff HEAD^ #{$1}'
|
56
|
+
],
|
57
|
+
[
|
58
|
+
"「(#{files.join('|')})」ファイルをふたつ前のコミットと比較する",
|
59
|
+
'git diff HEAD^^ #{$1}'
|
60
|
+
],
|
61
|
+
[
|
62
|
+
"「(#{files.join('|')})」ファイルをひとつ前のバージョンと比較する",
|
63
|
+
'git log --oneline #{$1} | head -2 | tail -1 | awk \'{print $1}\' | xargs -J xxx git diff xxx #{$1}'
|
64
|
+
],
|
65
|
+
[
|
66
|
+
"ひとつ前のバージョンの「(#{files.join('|')})」ファイルと現在のものを比較する",
|
67
|
+
'git log --oneline #{$1} | head -2 | tail -1 | awk \'{print $1}\' | xargs -J xxx git diff xxx #{$1}'
|
68
|
+
],
|
69
|
+
] : [] +
|
70
|
+
[
|
71
|
+
[
|
72
|
+
"(#{numbers.join('|')})分前から(変化した|変わった|変更された)ファイルをリストする",
|
73
|
+
'githelp-changed \'#{$1} minutes ago\''
|
74
|
+
],
|
75
|
+
[
|
76
|
+
"(#{numbers.join('|')})時間前から(変化した|変わった|変更された)ファイルをリストする",
|
77
|
+
'githelp-changed \'#{$1} hours ago\''
|
78
|
+
],
|
79
|
+
[
|
80
|
+
"(#{numbers.join('|')})日前から(変化した|変わった|変更された)ファイルをリストする",
|
81
|
+
'githelp-changed \'#{$1} days ago\''
|
82
|
+
],
|
83
|
+
[
|
84
|
+
"(#{numbers.join('|')})分前から(変化してない|変わってない|変わらない|変更されてない)ファイルをリストする",
|
85
|
+
'githelp-unchanged \'#{$1} minutes ago\''
|
86
|
+
],
|
87
|
+
[
|
88
|
+
"(#{numbers.join('|')})時間前から(変化してない|変わってない|変わらない|変更されてない)ファイルをリストする",
|
89
|
+
'githelp-unchanged \'#{$1} hours ago\''
|
90
|
+
],
|
91
|
+
[
|
92
|
+
"(#{numbers.join('|')})日前から(変化してない|変わってない|変わらない|変更されてない)ファイルをリストする",
|
93
|
+
'githelp-unchanged \'#{$1} days ago\''
|
94
|
+
],
|
95
|
+
]
|
data/data/checkout.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
[
|
3
|
+
[
|
4
|
+
"「(#{branches.join('|')})」ブランチの最新状態に移動する",
|
5
|
+
'git checkout #{$1} '
|
6
|
+
],
|
7
|
+
[
|
8
|
+
"最新の状態に戻す",
|
9
|
+
'git checkout #{branch}'
|
10
|
+
],
|
11
|
+
[
|
12
|
+
"(#{numbers.join('|')})分前の状態に一時的に戻す",
|
13
|
+
'git checkout "@{#{$1} minutes ago}"'
|
14
|
+
],
|
15
|
+
[
|
16
|
+
"(#{numbers.join('|')})時間前の状態に一時的に戻す",
|
17
|
+
'git checkout "@{#{$1} hour ago}"'
|
18
|
+
],
|
19
|
+
[
|
20
|
+
"(#{numbers.join('|')})日前の状態に一時的に戻す",
|
21
|
+
'git checkout "@{#{$1} days ago}"'
|
22
|
+
],
|
23
|
+
[
|
24
|
+
"(#{files.join('|')})が追加されたコミットに一時的に戻す",
|
25
|
+
'githelp-fileadded #{$1} | xargs git checkout'
|
26
|
+
],
|
27
|
+
]
|
data/data/commit.rb
ADDED
data/data/freq.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# https://bayashi.net/diary/2015/0224
|
4
|
+
[
|
5
|
+
[
|
6
|
+
"(よく|頻繁に)(編集|修正)されているファイルを(リスト|表示)する",
|
7
|
+
'git log --name-only --pretty="format:" | grep -ve "^$" | sort | uniq -c | sort -r | more'
|
8
|
+
],
|
9
|
+
[
|
10
|
+
"ファイルの(編集|修正)のランキングを(リスト|表示)する",
|
11
|
+
'git log --name-only --pretty="format:" | grep -ve "^$" | sort | uniq -c | sort -r | more'
|
12
|
+
],
|
13
|
+
]
|
data/data/fresh.rb
ADDED
data/data/grep.rb
ADDED
data/data/ignore.rb
ADDED
data/data/log.rb
ADDED
data/data/ls-files.rb
ADDED
data/data/mv.rb
ADDED
data/data/removed.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
if params.length > 0 && files.length > 0
|
3
|
+
|
4
|
+
[
|
5
|
+
[
|
6
|
+
"「(#{files.join('|')})」ファイルから「(#{params.join('|')})」という名前が消えたのはいつ?",
|
7
|
+
'git log --oneline | awk \'{print $1}\' | xargs -J xxx git show xxx #{$1} | grep -C10 \'^-.*#{$2}\''
|
8
|
+
],
|
9
|
+
[
|
10
|
+
"「(#{params.join('|')})」という名前が「(#{files.join('|')})」ファイルから消えたのはいつ?",
|
11
|
+
'git log --oneline | awk \'{print $1}\' | xargs -J xxx git show xxx #{$2} | grep -C10 \'^-.*#{$1}\''
|
12
|
+
]
|
13
|
+
]
|
14
|
+
else
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
data/data/reset.rb
ADDED
data/data/rm.rb
ADDED
data/data/shortlog.rb
ADDED
data/data/show.rb
ADDED
data/data/status.rb
ADDED
data/data/tag.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
if params.length > 0
|
3
|
+
[
|
4
|
+
[
|
5
|
+
"現在使われているタグを(リスト|表示)する",
|
6
|
+
'git tag'
|
7
|
+
],
|
8
|
+
[
|
9
|
+
"現在のコミットIDに「(#{params.join('|')})」というタグを関連付けする",
|
10
|
+
'git tag #{$1}'
|
11
|
+
],
|
12
|
+
[
|
13
|
+
"「(#{params.join('|')})」というタグを現在のコミットIDに関連付けする",
|
14
|
+
'git tag #{$1}'
|
15
|
+
],
|
16
|
+
[
|
17
|
+
"「(#{tags.join('|')})」というタグを(削除する|消す)",
|
18
|
+
'git tag -d #{$1}'
|
19
|
+
],
|
20
|
+
[
|
21
|
+
"「(#{tags.join('|')})」というタグのついたコミットを表示する",
|
22
|
+
'git show #{$1}'
|
23
|
+
],
|
24
|
+
]
|
25
|
+
else
|
26
|
+
nil
|
27
|
+
end
|
data/data.txt
ADDED
data/exe/githelp
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
#
|
4
|
+
# GitHelp: ExpandHelpでGitを使いこなす
|
5
|
+
#
|
6
|
+
# % githelp # usage
|
7
|
+
# % githelp README 8時間 比較 # マッチする候補を表示
|
8
|
+
# % githelp -i README 8時間 比較 # マッチする候補を表示して選択
|
9
|
+
#
|
10
|
+
|
11
|
+
# 追加すべきデータはdata.txtに書く
|
12
|
+
|
13
|
+
require "bundler/setup"
|
14
|
+
require "githelp"
|
15
|
+
|
16
|
+
include Githelp
|
17
|
+
|
18
|
+
progpath = $0
|
19
|
+
if File.symlink?(progpath)
|
20
|
+
progpath = File.readlink(progpath)
|
21
|
+
end
|
22
|
+
progdir = "#{File.dirname(progpath)}"
|
23
|
+
|
24
|
+
opt_i = false
|
25
|
+
opt_x = nil
|
26
|
+
i = 0
|
27
|
+
ARGV.dup.each { |arg|
|
28
|
+
if arg == "-i"
|
29
|
+
opt_i = true
|
30
|
+
ARGV.delete_at(i)
|
31
|
+
elsif opt_x == ''
|
32
|
+
opt_x = arg.to_i
|
33
|
+
ARGV.delete_at(i)
|
34
|
+
elsif arg =~ /^-x(\d*)/
|
35
|
+
if $1.to_s != ''
|
36
|
+
opt_x = $1.to_i
|
37
|
+
else
|
38
|
+
opt_x = ''
|
39
|
+
end
|
40
|
+
ARGV.delete_at(i)
|
41
|
+
else
|
42
|
+
i += 1
|
43
|
+
end
|
44
|
+
}
|
45
|
+
|
46
|
+
list = githelp(" #{args.join(' ')} ")
|
47
|
+
if opt_x then
|
48
|
+
cmd = list[opt_x][1]
|
49
|
+
system "PATH=$PATH:#{progdir}/bin; (#{cmd})"
|
50
|
+
exit
|
51
|
+
else
|
52
|
+
IO.popen("more","w"){ |f|
|
53
|
+
list.each_with_index { |entry,ind|
|
54
|
+
f.puts "[#{ind}] #{entry[0]}"
|
55
|
+
f.puts " % " + entry[1]
|
56
|
+
}
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
if opt_i then
|
61
|
+
if list.length > 0 then
|
62
|
+
print "実行するコマンドの番号を入力して下さい > "
|
63
|
+
s = STDIN.readline
|
64
|
+
if s =~ /[0-9]/ then
|
65
|
+
i = s.to_i
|
66
|
+
if i >= 0 && i < list.length then
|
67
|
+
cmd = list[i][1]
|
68
|
+
puts cmd
|
69
|
+
system "PATH=$PATH:#{progdir}/bin; (#{cmd})"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/exe/githelp-changed
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
progpath = $0
|
5
|
+
progpath = File.expand_path(progpath)
|
6
|
+
progdir = "#{File.dirname(progpath)}"
|
7
|
+
|
8
|
+
require "#{progdir}/../lib/files"
|
9
|
+
require "#{progdir}/../lib/args"
|
10
|
+
require "#{progdir}/../lib/changes"
|
11
|
+
|
12
|
+
puts changed(ARGV[0])
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
filename = ARGV[0]
|
5
|
+
|
6
|
+
commit = nil
|
7
|
+
res = 'notfound'
|
8
|
+
|
9
|
+
`git log --name-status --oneline`.split(/\n/).each { |line|
|
10
|
+
if line =~ /^([0-9a-f]{7})/
|
11
|
+
commit = $1
|
12
|
+
else
|
13
|
+
line.chomp!
|
14
|
+
a = line.split(/\s+/)
|
15
|
+
if a[1] == filename
|
16
|
+
res = commit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
}
|
20
|
+
|
21
|
+
if ARGV[1] == 'range'
|
22
|
+
puts "#{res}^..#{res}"
|
23
|
+
else
|
24
|
+
puts res
|
25
|
+
end
|
data/githelp.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'githelp/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "githelp"
|
8
|
+
spec.version = Githelp::VERSION
|
9
|
+
spec.authors = ["Toshiyuki Masui"]
|
10
|
+
spec.email = ["masui@pitecan.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{GitHelp - long summary}
|
13
|
+
spec.description = %q{GitHelp - short desc}
|
14
|
+
spec.homepage = "http://GitHub.com/masui/GitHelp"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib", "data", "bin"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest"
|
25
|
+
spec.add_development_dependency "re_expand"
|
26
|
+
end
|
data/lib/githelp/args.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
|
4
|
+
module Githelp
|
5
|
+
def args(argv=ARGV)
|
6
|
+
a = []
|
7
|
+
argv.each { |arg|
|
8
|
+
if arg =~ /^(\d+)([^\d]+)?$/ then
|
9
|
+
a << $1
|
10
|
+
a << $2 if $2.to_s != ''
|
11
|
+
else
|
12
|
+
a << arg.sub(/^['"]/,'').sub(/['"]$/,'').sub('「','').sub('」','')
|
13
|
+
end
|
14
|
+
}
|
15
|
+
a.length > 0 ? a : ['']
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Githelp
|
4
|
+
def branches
|
5
|
+
`git branch`.split(/\n/).map { |line|
|
6
|
+
line.chomp!
|
7
|
+
line.sub(/^../,'')
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def branch
|
12
|
+
`git branch`.split(/\n/).map { |line|
|
13
|
+
line.chomp!
|
14
|
+
if line =~ /^\* (.*)$/ then
|
15
|
+
return $1
|
16
|
+
end
|
17
|
+
}
|
18
|
+
''
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Githelp
|
4
|
+
def changed(since)
|
5
|
+
files(true).find_all { |file|
|
6
|
+
`git log --oneline --since='#{since}' #{file} | wc` !~ / 0 /
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
def unchanged(since)
|
11
|
+
files(true).find_all { |file|
|
12
|
+
`git log --oneline --since='#{since}' #{file} | wc` =~ / 0 /
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# 見えるファイル名のリストを作る
|
4
|
+
#
|
5
|
+
|
6
|
+
def files(force=false, argv=ARGV)
|
7
|
+
#
|
8
|
+
# 引数の中にファイル名とマッチするものがあればファイルリストを取得
|
9
|
+
#
|
10
|
+
list = `git ls-files`.split(/\n/)
|
11
|
+
matched = false
|
12
|
+
list.each { |file|
|
13
|
+
args.each { |arg|
|
14
|
+
matched = true if file.match arg
|
15
|
+
}
|
16
|
+
}
|
17
|
+
if (argv.length > 0 && matched) || force
|
18
|
+
list
|
19
|
+
else
|
20
|
+
['##DUMMYFILE##']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Githelp
|
4
|
+
#def branch
|
5
|
+
# "(ブランチ|branch)"
|
6
|
+
#end
|
7
|
+
|
8
|
+
# def mins
|
9
|
+
# "(1|2|3|4|5|6|7|8|9|10|20|30|40|50)"
|
10
|
+
# end
|
11
|
+
# def hours
|
12
|
+
# "(1|2|4|6|8|10|12|18)"
|
13
|
+
# end
|
14
|
+
# def days
|
15
|
+
# "(1|2|3|4|5|6|7|8|9|10)"
|
16
|
+
# end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
|
4
|
+
module Githelp
|
5
|
+
def params(argv=ARGV)
|
6
|
+
a = []
|
7
|
+
argv.each { |arg|
|
8
|
+
if arg =~ /^(\d+)[^\d]*$/ then
|
9
|
+
# a << $1
|
10
|
+
elsif arg =~ /^'.*'$/ || arg =~ /^".*"$/ || arg =~ /^「.*」$/
|
11
|
+
a << arg.sub(/^['"]/,'').sub(/['"]$/,'').sub('「','').sub('」','')
|
12
|
+
end
|
13
|
+
}
|
14
|
+
a.length > 0 ? a : ['##DUMMYNAME##']
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
|
4
|
+
module Githelp
|
5
|
+
def patterns(argv=ARGV)
|
6
|
+
a = []
|
7
|
+
argv.each { |arg|
|
8
|
+
if arg =~ /^(\d+)[^\d]*$/ then
|
9
|
+
# a << $1
|
10
|
+
elsif arg =~ /^'.*'$/ || arg =~ /^".*"$/ || arg =~ /^「.*」$/
|
11
|
+
# a << arg.sub(/^['"]/,'').sub(/['"]$/,'').sub('「','').sub('」','')
|
12
|
+
else
|
13
|
+
a << arg
|
14
|
+
end
|
15
|
+
}
|
16
|
+
a.length > 0 ? a : ['##PATTERN##']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
data/lib/githelp/tags.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# 存在するタグのリストを作る
|
4
|
+
#
|
5
|
+
|
6
|
+
module Githelp
|
7
|
+
def tags(force=false,argv=ARGV)
|
8
|
+
#
|
9
|
+
# 引数の中にタグ名とマッチするものがあればタグリストを取得
|
10
|
+
#
|
11
|
+
list = `git tag`.split(/\n/)
|
12
|
+
matched = false
|
13
|
+
list.each { |tag|
|
14
|
+
args.each { |arg|
|
15
|
+
matched = true if tag.match arg
|
16
|
+
}
|
17
|
+
}
|
18
|
+
if (argv.length > 0 && matched) || force
|
19
|
+
list
|
20
|
+
else
|
21
|
+
['##DUMMYTAG##']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
data/lib/githelp.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require "githelp/version"
|
4
|
+
require 're_expand'
|
5
|
+
|
6
|
+
require "githelp/args"
|
7
|
+
require "githelp/files"
|
8
|
+
require "githelp/params"
|
9
|
+
require "githelp/patterns"
|
10
|
+
require "githelp/tags"
|
11
|
+
require "githelp/numbers"
|
12
|
+
require "githelp/branches"
|
13
|
+
require "githelp/changes"
|
14
|
+
require "githelp/glossary"
|
15
|
+
|
16
|
+
module Githelp
|
17
|
+
#
|
18
|
+
# パタンを指定してコマンド候補リストを得る
|
19
|
+
#
|
20
|
+
def githelp(pat)
|
21
|
+
|
22
|
+
datadir = File.expand_path('../../data', __FILE__)
|
23
|
+
# $LOAD_PATH.unshift File.expand_path('../data', __FILE__)
|
24
|
+
|
25
|
+
entries = []
|
26
|
+
Dir.open(datadir).each { |file|
|
27
|
+
next unless File.file?("#{datadir}/#{file}")
|
28
|
+
next if file !~ /\.rb$/
|
29
|
+
# require file
|
30
|
+
a = eval File.read("#{datadir}/#{file}")
|
31
|
+
entries += a if a
|
32
|
+
}
|
33
|
+
|
34
|
+
g = ExpandRuby::Generator.new # re_expandのジェネレータ
|
35
|
+
entries.each { |entry|
|
36
|
+
g.add entry[0], entry[1] if entry
|
37
|
+
}
|
38
|
+
res = g.generate pat
|
39
|
+
listed = {}
|
40
|
+
res[0].find_all { |a| # 0 ambig
|
41
|
+
if listed[a[1]]
|
42
|
+
false
|
43
|
+
else
|
44
|
+
listed[a[1]] = true
|
45
|
+
end
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# require 're_expand'
|
51
|
+
#
|
52
|
+
# $libdir = File.dirname(__FILE__)
|
53
|
+
# require "#{$libdir}/files"
|
54
|
+
# require "#{$libdir}/args"
|
55
|
+
# require "#{$libdir}/params"
|
56
|
+
# require "#{$libdir}/patterns"
|
57
|
+
# require "#{$libdir}/tags"
|
58
|
+
# require "#{$libdir}/numbers"
|
59
|
+
# require "#{$libdir}/branches"
|
60
|
+
# require "#{$libdir}/changes"
|
61
|
+
# require "#{$libdir}/glossary"
|
62
|
+
#
|
63
|
+
# #
|
64
|
+
# # パタンを指定してコマンド候補リストを得る
|
65
|
+
# #
|
66
|
+
# def githelp(pat)
|
67
|
+
# datadir = "#{$libdir}/../data"
|
68
|
+
#
|
69
|
+
# entries = []
|
70
|
+
# Dir.open(datadir).each { |file|
|
71
|
+
# next unless File.file?("#{datadir}/#{file}")
|
72
|
+
# next if file !~ /\.rb$/
|
73
|
+
# a = eval File.read("#{datadir}/#{file}")
|
74
|
+
# entries += a if a
|
75
|
+
# }
|
76
|
+
#
|
77
|
+
# g = ExpandRuby::Generator.new # re_expandのジェネレータ
|
78
|
+
# entries.each { |entry|
|
79
|
+
# g.add entry[0], entry[1] if entry
|
80
|
+
# }
|
81
|
+
# res = g.generate pat
|
82
|
+
# listed = {}
|
83
|
+
# res[0].find_all { |a| # 0 ambig
|
84
|
+
# if listed[a[1]]
|
85
|
+
# false
|
86
|
+
# else
|
87
|
+
# listed[a[1]] = true
|
88
|
+
# end
|
89
|
+
# }
|
90
|
+
# end
|
91
|
+
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: githelp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Toshiyuki Masui
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: re_expand
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: GitHelp - short desc
|
70
|
+
email:
|
71
|
+
- masui@pitecan.com
|
72
|
+
executables:
|
73
|
+
- githelp
|
74
|
+
- githelp-changed
|
75
|
+
- githelp-fileadded
|
76
|
+
- githelp-unchanged
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- ".gitignore"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- Makefile
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- data.txt
|
87
|
+
- data/adddelete.rb
|
88
|
+
- data/afteradd.rb
|
89
|
+
- data/appear.rb
|
90
|
+
- data/branch.rb
|
91
|
+
- data/cat-file.rb
|
92
|
+
- data/change.rb
|
93
|
+
- data/checkout.rb
|
94
|
+
- data/commit.rb
|
95
|
+
- data/freq.rb
|
96
|
+
- data/fresh.rb
|
97
|
+
- data/grep.rb
|
98
|
+
- data/ignore.rb
|
99
|
+
- data/log.rb
|
100
|
+
- data/ls-files.rb
|
101
|
+
- data/mv.rb
|
102
|
+
- data/removed.rb
|
103
|
+
- data/reset.rb
|
104
|
+
- data/rm.rb
|
105
|
+
- data/shortlog.rb
|
106
|
+
- data/show.rb
|
107
|
+
- data/status.rb
|
108
|
+
- data/tag.rb
|
109
|
+
- exe/githelp
|
110
|
+
- exe/githelp-changed
|
111
|
+
- exe/githelp-fileadded
|
112
|
+
- exe/githelp-unchanged
|
113
|
+
- githelp.gemspec
|
114
|
+
- lib/githelp.rb
|
115
|
+
- lib/githelp/args.rb
|
116
|
+
- lib/githelp/branches.rb
|
117
|
+
- lib/githelp/changes.rb
|
118
|
+
- lib/githelp/files.rb
|
119
|
+
- lib/githelp/glossary.rb
|
120
|
+
- lib/githelp/numbers.rb
|
121
|
+
- lib/githelp/params.rb
|
122
|
+
- lib/githelp/patterns.rb
|
123
|
+
- lib/githelp/tags.rb
|
124
|
+
- lib/githelp/version.rb
|
125
|
+
homepage: http://GitHub.com/masui/GitHelp
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
- data
|
134
|
+
- bin
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.2.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: GitHelp - long summary
|
151
|
+
test_files: []
|