githelp 0.1.4 → 0.2.1

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.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.config/peco/config.json +6 -0
  3. data/00README +8 -0
  4. data/Gemfile +2 -4
  5. data/Makefile +10 -0
  6. data/README.md +9 -122
  7. data/bin/gh +2 -0
  8. data/exe/getghdata +100 -0
  9. data/exe/githelp +42 -67
  10. data/getdata +100 -0
  11. data/githelp +57 -0
  12. metadata +13 -52
  13. data/LICENSE.txt +0 -21
  14. data/Rakefile +0 -10
  15. data/bin/console +0 -14
  16. data/bin/setup +0 -7
  17. data/data.txt +0 -12
  18. data/data/adddelete.rb +0 -10
  19. data/data/afteradd.rb +0 -16
  20. data/data/appear.rb +0 -16
  21. data/data/branch.rb +0 -33
  22. data/data/cat-file.rb +0 -19
  23. data/data/change.rb +0 -95
  24. data/data/checkout.rb +0 -27
  25. data/data/commit.rb +0 -7
  26. data/data/freq.rb +0 -13
  27. data/data/fresh.rb +0 -7
  28. data/data/grep.rb +0 -8
  29. data/data/ignore.rb +0 -11
  30. data/data/log.rb +0 -8
  31. data/data/ls-files.rb +0 -15
  32. data/data/mv.rb +0 -7
  33. data/data/removed.rb +0 -17
  34. data/data/reset.rb +0 -11
  35. data/data/rm.rb +0 -8
  36. data/data/shortlog.rb +0 -13
  37. data/data/show.rb +0 -7
  38. data/data/status.rb +0 -11
  39. data/data/tag.rb +0 -27
  40. data/exe/githelp-changed +0 -9
  41. data/exe/githelp-fileadded +0 -25
  42. data/exe/githelp-unchanged +0 -9
  43. data/githelp.gemspec +0 -28
  44. data/lib/githelp.rb +0 -51
  45. data/lib/githelp/args.rb +0 -17
  46. data/lib/githelp/branches.rb +0 -40
  47. data/lib/githelp/changes.rb +0 -36
  48. data/lib/githelp/files.rb +0 -27
  49. data/lib/githelp/git_check.rb +0 -15
  50. data/lib/githelp/glossary.rb +0 -17
  51. data/lib/githelp/numbers.rb +0 -14
  52. data/lib/githelp/params.rb +0 -17
  53. data/lib/githelp/patterns.rb +0 -20
  54. data/lib/githelp/tags.rb +0 -29
  55. data/lib/githelp/version.rb +0 -3
data/data/commit.rb DELETED
@@ -1,7 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "直前のコミットのコメントを修正する",
5
- "git commit --amend"
6
- ],
7
- ]
data/data/freq.rb DELETED
@@ -1,13 +0,0 @@
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 DELETED
@@ -1,7 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "ファイルを新しい順に(リスト|表示)する",
5
- "git ls-files | xargs ls -1 -t"
6
- ],
7
- ]
data/data/grep.rb DELETED
@@ -1,8 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "「(#{params.join('|')})」という文字列を含むファイルを(リスト|表示)する",
5
- 'git grep --name-only #{$1}'
6
- ],
7
- ]
8
-
data/data/ignore.rb DELETED
@@ -1,11 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "(Gitで?)管理されていないファイルを(表示する|見る|リストする)",
5
- 'git ls-files --exclude-standard --others --ignored'
6
- ],
7
- [
8
- "(Gitで?)管理されていないファイルのリストを(表示する|見る)",
9
- 'git ls-files --exclude-standard --others --ignored'
10
- ],
11
- ]
data/data/log.rb DELETED
@@ -1,8 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "(#{files.join('|')})が追加されたコミットの(情報|ログ)を表示する",
5
- 'git log --format="%h" #{$1} | tail -1 | xargs -J xxxx git log xxxx #{$1}'
6
- # 'githelp-fileadded #{$1} range | xargs git log' ログの範囲は abcde^..abcde みたいに指定する必要があるがこれを生成するのが難しい!
7
- ],
8
- ]
data/data/ls-files.rb DELETED
@@ -1,15 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "(Gitで?)管理されているファイルを(表示する|見る|リストする)",
5
- 'git ls-files'
6
- ],
7
- [
8
- "(Gitで?)管理されているファイルのリストを(表示する|見る)",
9
- 'git ls-files'
10
- ],
11
- [
12
- "(Gitで?)管理されているファイルの(大きさ|サイズ)をリストする",
13
- 'git ls-files | xargs wc'
14
- ],
15
- ]
data/data/mv.rb DELETED
@@ -1,7 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "「(#{files.join('|')})」というファイルを「(#{params.join('|')})」という名前に((変更|移動|改名|リネーム)する|変える)",
5
- 'git mv #{$1} #{$2}'
6
- ]
7
- ]
data/data/removed.rb DELETED
@@ -1,17 +0,0 @@
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 DELETED
@@ -1,11 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "直前のコミットを取り消す",
5
- "git reset --soft HEAD^"
6
- ],
7
- [
8
- "直前のコミットを完全に取り消す",
9
- "git reset --hard HEAD^"
10
- ]
11
- ]
data/data/rm.rb DELETED
@@ -1,8 +0,0 @@
1
- # coding: utf-8
2
-
3
- [
4
- [
5
- "「(#{files.join('|')})」というファイルを(削除する|消す)",
6
- 'git rm #{$1}'
7
- ]
8
- ]
data/data/shortlog.rb DELETED
@@ -1,13 +0,0 @@
1
- # coding: utf-8
2
-
3
- # coding: utf-8
4
- [
5
- [
6
- "コミッタのランキングを表示する",
7
- 'git shortlog -sn'
8
- ],
9
- [
10
- "コミッタのコミット数を表示する",
11
- 'git shortlog -sn'
12
- ],
13
- ]
data/data/show.rb DELETED
@@ -1,7 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "「(#{files.join('|')})」ファイルの状況を(表示する|見る)",
5
- 'git show head:#{$1}'
6
- ],
7
- ]
data/data/status.rb DELETED
@@ -1,11 +0,0 @@
1
- # coding: utf-8
2
- [
3
- [
4
- "現在の状況を(知る|見る)",
5
- 'git status'
6
- ],
7
- [
8
- "変更されたファイルをリストする",
9
- 'git status'
10
- ],
11
- ]
data/data/tag.rb DELETED
@@ -1,27 +0,0 @@
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/exe/githelp-changed DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "bundler/setup"
5
- require "githelp"
6
-
7
- include Githelp
8
-
9
- puts changed(ARGV[0])
@@ -1,25 +0,0 @@
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
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "bundler/setup"
5
- require "githelp"
6
-
7
- include Githelp
8
-
9
- puts unchanged(ARGV[0])
data/githelp.gemspec DELETED
@@ -1,28 +0,0 @@
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.executables = ["githelp", "githelp-changed"]
21
- spec.require_paths = ["lib", "data"]
22
-
23
- spec.add_development_dependency "bundler", "~> 1.10"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "minitest"
26
-
27
- spec.add_runtime_dependency "re_expand"
28
- end
data/lib/githelp.rb DELETED
@@ -1,51 +0,0 @@
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
- require "githelp/git_check"
16
-
17
- module Githelp
18
- #
19
- # パタンを指定してコマンド候補リストを得る
20
- #
21
- def githelp(pat)
22
-
23
- datadir = File.expand_path('../../data', __FILE__)
24
- # $LOAD_PATH.unshift File.expand_path('../data', __FILE__)
25
-
26
- entries = []
27
- Dir.open(datadir).each { |file|
28
- next unless File.file?("#{datadir}/#{file}")
29
- next if file !~ /\.rb$/
30
- # require file
31
- a = eval File.read("#{datadir}/#{file}")
32
- entries += a if a
33
- }
34
-
35
- g = ExpandRuby::Generator.new # re_expandのジェネレータ
36
- entries.each { |entry|
37
- g.add entry[0], entry[1] if entry
38
- }
39
- res = g.generate pat
40
- listed = {}
41
- res[0].find_all { |a| # 0 ambig
42
- if listed[a[1]]
43
- false
44
- else
45
- listed[a[1]] = true
46
- end
47
- }
48
- end
49
- end
50
-
51
-
data/lib/githelp/args.rb DELETED
@@ -1,17 +0,0 @@
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
@@ -1,40 +0,0 @@
1
- # coding: utf-8
2
-
3
- module Githelp
4
- def git_branch
5
- begin
6
- `git branch`
7
- rescue
8
- nil
9
- end
10
- end
11
-
12
- def branches
13
- b = git_branch
14
- if b
15
- b.split(/\n/).map { |line|
16
- line.chomp!
17
- line.sub(/^../,'')
18
- }
19
- else
20
- [ '##BRANCH##' ]
21
- end
22
- end
23
-
24
- def branch
25
- b = git_branch
26
- if b
27
- b.split(/\n/).map { |line|
28
- line.chomp!
29
- if line =~ /^\* (.*)$/ then
30
- return $1
31
- end
32
- }
33
- ''
34
- else
35
- ''
36
- end
37
- end
38
- end
39
-
40
-
@@ -1,36 +0,0 @@
1
- # coding: utf-8
2
-
3
- module Githelp
4
- def git_log_wc(since,file)
5
- begin
6
- `git log --oneline --since='#{since}' #{file} | wc`
7
- rescue
8
- nil
9
- end
10
- end
11
-
12
- def changed(since)
13
- files(true).find_all { |file|
14
- wc = git_log_wc(since,file)
15
- if wc
16
- wc !~ / 0 /
17
- else
18
- false
19
- end
20
- }
21
- end
22
-
23
- def unchanged(since)
24
- files(true).find_all { |file|
25
- wc = git_log_wc(since,file)
26
- if wc
27
- wc =~ / 0 /
28
- else
29
- false
30
- end
31
- }
32
- end
33
- end
34
-
35
-
36
-
data/lib/githelp/files.rb DELETED
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- #
3
- # 見えるファイル名のリストを作る
4
- #
5
-
6
- def files(force=false, argv=ARGV)
7
- #
8
- # 引数の中にファイル名とマッチするものがあればファイルリストを取得
9
- #
10
- list = begin
11
- `git ls-files`.split(/\n/)
12
- rescue
13
- []
14
- end
15
- matched = false
16
- list.each { |file|
17
- args.each { |arg|
18
- matched = true if file.match arg
19
- }
20
- }
21
- if (argv.length > 0 && matched) || force
22
- list
23
- else
24
- ['##DUMMYFILE##']
25
- end
26
- end
27
-