githelp 0.2.11 → 0.2.12
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/Makefile +1 -1
- data/backups/GitHelp.json +751 -0
- data/exe/githelp +153 -45
- data/lib/githelp/version.rb +1 -1
- metadata +3 -8
- data/exe/getghdata +0 -100
- data/exe/gh +0 -11
- data/getdata +0 -100
- data/githelp +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a8f64a2cbc041c7915535f351325dccb66c68aaa6ee6c203c332b2fac9b3179
|
4
|
+
data.tar.gz: b360f37c13309eeb4df292f56447280ad5961cebaf3b72071e6e7eff00a88109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4414c48c3b37a0648416b929ad5186fc0b433124ee8864d326be6e2710dff53d84119723bcff5207bfd606d2d3f93ed341d4c5e22ced879150ef1e4759666d77
|
7
|
+
data.tar.gz: acf298abcf52075d4a8c53013fa6d856424ce6b2a8a85991f0f89f7d6fe748d8705f673b3cad386528f4248548bb5d5760a1c59bf1b59bf74db70b5447b9cbc1
|
data/Makefile
CHANGED
@@ -0,0 +1,751 @@
|
|
1
|
+
{
|
2
|
+
"name": "GitHelp",
|
3
|
+
"displayName": "GitHelp",
|
4
|
+
"exported": 1520432471,
|
5
|
+
"pages": [
|
6
|
+
{
|
7
|
+
"title": "このサイトについて",
|
8
|
+
"created": 1491961323,
|
9
|
+
"updated": 1520299996,
|
10
|
+
"lines": [
|
11
|
+
"このサイトについて",
|
12
|
+
" [https://scrapbox.io/projects/GitHelp/invitations/72392c14f9584cd15b7eb9c670547ed6 招待リンク]",
|
13
|
+
" [https://github.com/masui/GitHelp GitHelp] のデータをScrapbox上で編集する",
|
14
|
+
" 例えば以下のようなデータをScrapboxページに書いておくとgithelpコマンドができる",
|
15
|
+
" e.g. `(よく|頻繁に)(編集|修正)されているファイルを(リスト|表示)する`",
|
16
|
+
" [ファイルの編集回数のランキング]のような書き方を使う",
|
17
|
+
" 人間がわかる表現を正規表現で`$ xxx ...` と書く",
|
18
|
+
" その実行コマンドを`% git ...`と書く",
|
19
|
+
" ユーザが「ランキング」とか入力するとこの説明が[/icons/わかる.icon]",
|
20
|
+
" 関数やマクロもScrapboxで定義する",
|
21
|
+
" コード記法を利用",
|
22
|
+
" 目標: UIST2018投稿",
|
23
|
+
"",
|
24
|
+
""
|
25
|
+
]
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"title": "Gitの様々なundo",
|
29
|
+
"created": 1492827192,
|
30
|
+
"updated": 1492827231,
|
31
|
+
"lines": [
|
32
|
+
"Gitの様々なundo",
|
33
|
+
"https://github.com/blog/2019-how-to-undo-almost-anything-with-git"
|
34
|
+
]
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"title": "ファイルの編集回数のランキング",
|
38
|
+
"created": 1492827356,
|
39
|
+
"updated": 1520226397,
|
40
|
+
"lines": [
|
41
|
+
"ファイルの編集回数のランキング",
|
42
|
+
"$ ファイルの(編集|修正)のランキングを(リスト|表示)する",
|
43
|
+
"$ (よく|頻繁に)(編集|修正)(されてる|されている)ファイルを(リスト|表示)する",
|
44
|
+
"% git log --name-only --pretty=\"format:\" | grep -ve \"^$\" | sort | uniq -c | sort -r | more",
|
45
|
+
"",
|
46
|
+
"#ランキング #編集 #修正"
|
47
|
+
]
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"title": "ファイル追加",
|
51
|
+
"created": 1495151660,
|
52
|
+
"updated": 1520206327,
|
53
|
+
"lines": [
|
54
|
+
"ファイル追加",
|
55
|
+
"$ 最初に「(#{params})」という文字列を含むコミットをした時から現在までに追加されたファイルはどれとどれ?",
|
56
|
+
"% git log --oneline --date=iso-strict --format='%cd %s' | grep #{$1} | tail -1 | awk '{print $1}' | xargs githelp-changed",
|
57
|
+
""
|
58
|
+
]
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"title": "引数パラメタ",
|
62
|
+
"created": 1495152243,
|
63
|
+
"updated": 1520227476,
|
64
|
+
"lines": [
|
65
|
+
"引数パラメタ",
|
66
|
+
" 引数で与えられたパラメタ",
|
67
|
+
" githelp 'abc'",
|
68
|
+
" ', \" で囲む?",
|
69
|
+
"",
|
70
|
+
"code:params.rb",
|
71
|
+
" def params(argv=ARGV)",
|
72
|
+
" a = []",
|
73
|
+
" argv.each { |arg|",
|
74
|
+
" if arg =~ /^(\\d+)[^\\d]*$/ then",
|
75
|
+
" # a << $1 ",
|
76
|
+
" elsif arg =~ /^'.*'$/ || arg =~ /^\".*\"$/ || arg =~ /^「.*」$/",
|
77
|
+
" a << arg.sub(/^['\"]/,'').sub(/['\"]$/,'').sub('「','').sub('」','')",
|
78
|
+
" else",
|
79
|
+
" a << arg",
|
80
|
+
" end",
|
81
|
+
" }",
|
82
|
+
" a.length > 0 ? a.join('|') : 'xxxxx'",
|
83
|
+
" end",
|
84
|
+
""
|
85
|
+
]
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"title": "増井俊之",
|
89
|
+
"created": 1496475568,
|
90
|
+
"updated": 1496475568,
|
91
|
+
"lines": [
|
92
|
+
"増井俊之",
|
93
|
+
"[https://i.gyazo.com/ce44a0adde8a39df00cfa744d8f42d95.png]"
|
94
|
+
]
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"title": "ファイル復元",
|
98
|
+
"created": 1496645946,
|
99
|
+
"updated": 1520227687,
|
100
|
+
"lines": [
|
101
|
+
"ファイル復元",
|
102
|
+
"$ (1つ|ひとつ)前のコミットで(削除した|消した)(#{files})を(復元する|元に戻す)",
|
103
|
+
"% git checkout $(git rev-list -n 1 HEAD -- #{$2})^ -- #{$2}",
|
104
|
+
"",
|
105
|
+
" `--` の後にファイル名を書ける (getoptの仕様)",
|
106
|
+
" `$(...)` は `\\`xxx`` と同じ (bashの記法)",
|
107
|
+
""
|
108
|
+
]
|
109
|
+
},
|
110
|
+
{
|
111
|
+
"title": "コミッタ(ユーザー)について調べる",
|
112
|
+
"created": 1496646067,
|
113
|
+
"updated": 1520218296,
|
114
|
+
"lines": [
|
115
|
+
"コミッタ(ユーザー)について調べる",
|
116
|
+
"",
|
117
|
+
"$ (コミッタ|ユーザー)のランキングを表示する",
|
118
|
+
"% git shortlog -sn",
|
119
|
+
"",
|
120
|
+
"#$ (#{numbers})週間の(コミッタ|ユーザー)の変更を(リスト|表示)する",
|
121
|
+
"#% git log --author=#{user} --since=#{$1}.week",
|
122
|
+
"",
|
123
|
+
"#$ (コミッタ|ユーザー)のこれまでの変更した行数を(リスト|表示)する",
|
124
|
+
"#% git log --author=#{user} --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s, removed lines: %s, total lines: %s\\n\", add, subs, loc }'",
|
125
|
+
""
|
126
|
+
]
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"title": "文字列の出現判定",
|
130
|
+
"created": 1496889295,
|
131
|
+
"updated": 1520226553,
|
132
|
+
"lines": [
|
133
|
+
"文字列の出現判定",
|
134
|
+
"$ (#{files})に(#{params})という名前が(出現した|書かれた)のはいつ?",
|
135
|
+
"% git blame #{$1} | grep #{$2}",
|
136
|
+
""
|
137
|
+
]
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"title": "ブランチ",
|
141
|
+
"created": 1496889490,
|
142
|
+
"updated": 1520404223,
|
143
|
+
"lines": [
|
144
|
+
"ブランチ",
|
145
|
+
"$ ブランチを(表示|リスト)する",
|
146
|
+
"% git branch",
|
147
|
+
"",
|
148
|
+
"$ 「(#{params})」というブランチを作成する",
|
149
|
+
"% git branch #{$1}",
|
150
|
+
"",
|
151
|
+
"$ 「(#{params})」というブランチを(#{delete})",
|
152
|
+
"% git branch -d #{$1}",
|
153
|
+
"",
|
154
|
+
""
|
155
|
+
]
|
156
|
+
},
|
157
|
+
{
|
158
|
+
"title": "古いファイル表示",
|
159
|
+
"created": 1496889662,
|
160
|
+
"updated": 1520425912,
|
161
|
+
"lines": [
|
162
|
+
"古いファイル表示",
|
163
|
+
"$ (#{numbers})分前の「(#{files})」ファイルを(#{display})",
|
164
|
+
"% git show '@{#{$1} minutes ago}':#{$2}",
|
165
|
+
"# % git cat-file -p '@{#{$1} minutes ago}':#{$2}",
|
166
|
+
"",
|
167
|
+
"$ (#{numbers})時間前の「(#{files})」ファイルを(#{display})",
|
168
|
+
"% git show '@{#{$1} hours ago}':#{$2}",
|
169
|
+
"",
|
170
|
+
"$ (#{numbers})日前の「(#{files})」ファイルを(#{display})",
|
171
|
+
"% git show '@{#{$1} days ago}':#{$2}",
|
172
|
+
"",
|
173
|
+
"$ 昨日の「(#{files})」ファイルを(#{display})",
|
174
|
+
"% git show @{yesterday}:#{$1}",
|
175
|
+
"",
|
176
|
+
"# $ 「(#{tags})」というタグがついているファイル「(#{files})」を(#{display})",
|
177
|
+
"# % git show #{$1} #{$2}",
|
178
|
+
"",
|
179
|
+
"#表示",
|
180
|
+
""
|
181
|
+
]
|
182
|
+
},
|
183
|
+
{
|
184
|
+
"title": "文字列の出現を調べる",
|
185
|
+
"created": 1497321083,
|
186
|
+
"updated": 1520236308,
|
187
|
+
"lines": [
|
188
|
+
"文字列の出現を調べる",
|
189
|
+
"$ (#{files})に(#{params})という名前が(出現した|書かれた)のはいつ?",
|
190
|
+
"% git blame #{$1} | grep #{$2}",
|
191
|
+
"",
|
192
|
+
"$ (#{params})という名前が(#{files})に(出現した|書かれた)のはいつ?",
|
193
|
+
"% git blame #{$2} | grep #{$1}",
|
194
|
+
"",
|
195
|
+
"fileがわからないときはどうするのか?",
|
196
|
+
""
|
197
|
+
]
|
198
|
+
},
|
199
|
+
{
|
200
|
+
"title": "ブランチの表示",
|
201
|
+
"created": 1497321104,
|
202
|
+
"updated": 1520404591,
|
203
|
+
"lines": [
|
204
|
+
"ブランチの表示",
|
205
|
+
"$ ブランチ(のリスト)?を(#{display})",
|
206
|
+
"% git branch",
|
207
|
+
"",
|
208
|
+
"$ (#{params})というブランチを作成する",
|
209
|
+
"% git branch #{$1}",
|
210
|
+
"",
|
211
|
+
"$ (#{branches})というブランチを(#{delete})",
|
212
|
+
"% git branch -d #Untitled",
|
213
|
+
""
|
214
|
+
]
|
215
|
+
},
|
216
|
+
{
|
217
|
+
"title": "やりたいことの例",
|
218
|
+
"created": 1519557995,
|
219
|
+
"updated": 1520413175,
|
220
|
+
"lines": [
|
221
|
+
"やりたいことの例",
|
222
|
+
" \"abc\" という文字列を含むファイルがいつどこでコミットされたか調べる",
|
223
|
+
" うっかりパスワードを書いてしまったファイルを過去コミットから削除する",
|
224
|
+
" しばらく変化ないファイルをリストする",
|
225
|
+
" ひとつ前との違いを見る",
|
226
|
+
" コミットメッセージからコミットを捜す",
|
227
|
+
" タグ関連いろいろ",
|
228
|
+
" reset",
|
229
|
+
" revert",
|
230
|
+
""
|
231
|
+
]
|
232
|
+
},
|
233
|
+
{
|
234
|
+
"title": "特定のファイルの履歴を消す",
|
235
|
+
"created": 1519563847,
|
236
|
+
"updated": 1520301084,
|
237
|
+
"lines": [
|
238
|
+
"特定のファイルの履歴を消す",
|
239
|
+
" パスワードを直書きしたファイルを間違ってアップロードしたときなど、どうする?",
|
240
|
+
" パスワードを含むファイルを捜す",
|
241
|
+
" git grep する",
|
242
|
+
" [変数や単語が出現しているファイルを捜す]",
|
243
|
+
" そのファイルを完全に履歴から消去する",
|
244
|
+
" という処理が必要だが、かなり難しいはず",
|
245
|
+
" こういうのをGitHelpできると嬉しいんじゃないだろうか",
|
246
|
+
" そういう解説があった",
|
247
|
+
" [https://help.github.com/articles/removing-sensitive-data-from-a-repository/ Removing sensitive data from a repository - User Documentation]",
|
248
|
+
" https://git-scm.com/book/ja/v1/Git-のさまざまなツール-歴史の書き換え",
|
249
|
+
"",
|
250
|
+
"xxxxxx.txtの履歴を消す",
|
251
|
+
" http://d.hatena.ne.jp/ichhi/20110825/1314300975",
|
252
|
+
" $ ファイル「(#{files})」の編集履歴を完全に(#{delete})がワーキングツリーは残す",
|
253
|
+
" % git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch #{$1}' HEAD",
|
254
|
+
"",
|
255
|
+
"GitHub の commit 履歴からパスワードファイル等だけを消す方法",
|
256
|
+
" https://qiita.com/MahoTakara/items/3b02bf55767a6372596e",
|
257
|
+
" $ ファイル「(#{files})」の編集履歴を完全に(#{delete})",
|
258
|
+
" % git filter-branch -f --index-filter 'git rm --ignore-unmatch #{$1}' HEAD",
|
259
|
+
"",
|
260
|
+
"どういう意味なのやら?",
|
261
|
+
" filter-branch というのは、大量コマンドを一気に実行するものらしい",
|
262
|
+
" 全部やるもの",
|
263
|
+
" --tree-filter チェックアウトしてコマンド実行",
|
264
|
+
" --index-filter インデックスに対してコマンド実行",
|
265
|
+
" git rm",
|
266
|
+
" --ignore-umatch",
|
267
|
+
" マッチしなくても続行する",
|
268
|
+
"",
|
269
|
+
"GitHubの方に反映させる",
|
270
|
+
"$ 編集履歴をGitHubに反映させる",
|
271
|
+
"% git push origin --force --all",
|
272
|
+
""
|
273
|
+
]
|
274
|
+
},
|
275
|
+
{
|
276
|
+
"title": "変数や単語が出現しているファイルを捜す",
|
277
|
+
"created": 1519691492,
|
278
|
+
"updated": 1520229686,
|
279
|
+
"lines": [
|
280
|
+
"変数や単語が出現しているファイルを捜す",
|
281
|
+
"間違ってパスワードなどをコミットしてないかチェック",
|
282
|
+
"",
|
283
|
+
" git grep というのがある",
|
284
|
+
" [https://qiita.com/zwirky/items/19df2d8d3d584da2790b 個人的によく使うgit grepのまとめ - Qiita]",
|
285
|
+
"",
|
286
|
+
"$ (#{params})という文字を含むファイルを捜す",
|
287
|
+
"% git grep #{$1}",
|
288
|
+
"",
|
289
|
+
"$ (#{params})という文字を含むファイルを全履歴から捜す",
|
290
|
+
"% git rev-list --all | xargs git grep #{$1}",
|
291
|
+
"",
|
292
|
+
"[変数がはじめて出現したバージョンを捜す]ことができるかも",
|
293
|
+
""
|
294
|
+
]
|
295
|
+
},
|
296
|
+
{
|
297
|
+
"title": "ツリー状にログを表示する",
|
298
|
+
"created": 1519698152,
|
299
|
+
"updated": 1520226251,
|
300
|
+
"lines": [
|
301
|
+
"ツリー状にログを表示する",
|
302
|
+
"$ ツリー状にログを表示する",
|
303
|
+
"% git log --graph --all --format=\"%x09%an%x09%h %d %s\"",
|
304
|
+
""
|
305
|
+
]
|
306
|
+
},
|
307
|
+
{
|
308
|
+
"title": "ファイル名変更",
|
309
|
+
"created": 1519809729,
|
310
|
+
"updated": 1520404600,
|
311
|
+
"lines": [
|
312
|
+
"ファイル名変更",
|
313
|
+
"$ 「(#{files})」というファイルを「(#{params})」という名前に(変更|移動|改名|リネーム)する",
|
314
|
+
"% git mv #{$1} #{$2}",
|
315
|
+
""
|
316
|
+
]
|
317
|
+
},
|
318
|
+
{
|
319
|
+
"title": "追加/削除された行数",
|
320
|
+
"created": 1519809816,
|
321
|
+
"updated": 1520234469,
|
322
|
+
"lines": [
|
323
|
+
"追加/削除された行数",
|
324
|
+
"$ これまで追加/削除された行数を表示する",
|
325
|
+
"% git log --numstat --pretty=\"%H\" | awk 'NF==3 {plus+=$1; minus+=$2} END {printf(\"+%d, -%d\\\\n\", plus, minus)}'",
|
326
|
+
""
|
327
|
+
]
|
328
|
+
},
|
329
|
+
{
|
330
|
+
"title": "古いファイルとの比較",
|
331
|
+
"created": 1519817302,
|
332
|
+
"updated": 1520425289,
|
333
|
+
"lines": [
|
334
|
+
"古いファイルとの比較",
|
335
|
+
"$ 「(#{files})」ファイルを(#{numbers})分前の(もの|バージョン)と比較する",
|
336
|
+
"$ 「(#{files})」ファイルが(#{numbers})分前から(変化した|変わった)ところを(#{display})",
|
337
|
+
"% git diff HEAD '@{#{$2} minutes ago}' #{$1}",
|
338
|
+
"",
|
339
|
+
"$ (#{numbers})分前の「(#{files})」ファイルと現在の(もの|バージョン)を比較する",
|
340
|
+
"% git diff HEAD @{#{$1}.minutes.ago} #{$2}",
|
341
|
+
"",
|
342
|
+
"$ (#{numbers})日前の「(#{files})」ファイルと現在のものを(比較する|比べる)",
|
343
|
+
"% git diff HEAD '@{#{$1} days ago}' #{$2}",
|
344
|
+
"",
|
345
|
+
"$ 現在の「(#{files})」ファイルを(#{numbers})日前のものを(比較する|比べる)",
|
346
|
+
"% git diff HEAD '@{#{$2} days ago}' #{$1}",
|
347
|
+
"",
|
348
|
+
"$ (1つ|ひとつ)前のバージョンの(#{files})と比較",
|
349
|
+
"$ (1つ|ひとつ)前のバージョンの(#{files})からの変更点",
|
350
|
+
"% git diff $(git rev-list -n 1 HEAD -- #{$2})^ -- #{$2}",
|
351
|
+
"",
|
352
|
+
"$ (#{files})の最新変更点",
|
353
|
+
"$ (#{files})の最新版の変更点",
|
354
|
+
"% git diff $(git rev-list -n 1 HEAD -- #{$1})^ -- #{$1}",
|
355
|
+
"",
|
356
|
+
"$ (2つ|ふたつ)前のバージョンの(#{files})と比較",
|
357
|
+
"$ (2つ|ふたつ)前のバージョンの(#{files})からの変更点",
|
358
|
+
"% git diff $(git rev-list -n 1 HEAD^^ -- #{$2}) -- #{$2}",
|
359
|
+
""
|
360
|
+
]
|
361
|
+
},
|
362
|
+
{
|
363
|
+
"title": "数字パラメタ",
|
364
|
+
"created": 1519905222,
|
365
|
+
"updated": 1520230812,
|
366
|
+
"lines": [
|
367
|
+
"数字パラメタ",
|
368
|
+
"code:numbers.rb",
|
369
|
+
" def numbers(argv=ARGV)",
|
370
|
+
" a = []",
|
371
|
+
" argv.each { |arg|",
|
372
|
+
" if arg =~ /^(\\d+)[^\\d]*$/ then",
|
373
|
+
" a << $1",
|
374
|
+
" end",
|
375
|
+
" }",
|
376
|
+
" # a.join(\"|\") ",
|
377
|
+
" a.length > 0 ? a.join(\"|\") : '1'",
|
378
|
+
" end",
|
379
|
+
" "
|
380
|
+
]
|
381
|
+
},
|
382
|
+
{
|
383
|
+
"title": "ファイルリスト",
|
384
|
+
"created": 1520137762,
|
385
|
+
"updated": 1520215308,
|
386
|
+
"lines": [
|
387
|
+
"ファイルリスト",
|
388
|
+
"引数の中にファイル名とマッチするものがあればファイルリストを取得 ",
|
389
|
+
"",
|
390
|
+
"code:files.rb",
|
391
|
+
" def files(argv=ARGV)",
|
392
|
+
" list = begin",
|
393
|
+
" `git ls-files`.split(/\\n/)",
|
394
|
+
" rescue",
|
395
|
+
" []",
|
396
|
+
" end",
|
397
|
+
" matched = {}",
|
398
|
+
" list.each { |file|",
|
399
|
+
" if argv.length == 0",
|
400
|
+
" matched[file] = true",
|
401
|
+
" else",
|
402
|
+
" args(argv).each { |arg|",
|
403
|
+
" matched[file] = true if file.match arg",
|
404
|
+
" }",
|
405
|
+
" end",
|
406
|
+
" }",
|
407
|
+
" files = list",
|
408
|
+
" files = matched.keys if matched.keys.length > 0",
|
409
|
+
" files.join(\"|\")",
|
410
|
+
" end",
|
411
|
+
"",
|
412
|
+
"[引数パラメタ]",
|
413
|
+
""
|
414
|
+
]
|
415
|
+
},
|
416
|
+
{
|
417
|
+
"title": "args",
|
418
|
+
"created": 1520160117,
|
419
|
+
"updated": 1520199968,
|
420
|
+
"lines": [
|
421
|
+
"args",
|
422
|
+
"code:args.rb",
|
423
|
+
" def args(argv=ARGV)",
|
424
|
+
" a = []",
|
425
|
+
" argv.each { |arg|",
|
426
|
+
" if arg =~ /^(\\d+)([^\\d]+)?$/ then",
|
427
|
+
" a << $1",
|
428
|
+
" a << $2 if $2.to_s != ''",
|
429
|
+
" else",
|
430
|
+
" a << arg.sub(/^['\"]/,'').sub(/['\"]$/,'').sub('「','').sub('」','')",
|
431
|
+
" end",
|
432
|
+
" }",
|
433
|
+
" a.length > 0 ? a : ['']",
|
434
|
+
" end",
|
435
|
+
""
|
436
|
+
]
|
437
|
+
},
|
438
|
+
{
|
439
|
+
"title": "ファイル削除",
|
440
|
+
"created": 1520212560,
|
441
|
+
"updated": 1520404321,
|
442
|
+
"lines": [
|
443
|
+
"ファイル削除",
|
444
|
+
"$ ファイル「(#{files})」を(#{delete})",
|
445
|
+
"% git rm #{$1}",
|
446
|
+
"",
|
447
|
+
"#削除",
|
448
|
+
""
|
449
|
+
]
|
450
|
+
},
|
451
|
+
{
|
452
|
+
"title": "コメント修正",
|
453
|
+
"created": 1520231491,
|
454
|
+
"updated": 1520287693,
|
455
|
+
"lines": [
|
456
|
+
"コメント修正",
|
457
|
+
"$ 直前のコミットのコメントを修正する",
|
458
|
+
"% git commit --amend",
|
459
|
+
""
|
460
|
+
]
|
461
|
+
},
|
462
|
+
{
|
463
|
+
"title": "Git情報源",
|
464
|
+
"created": 1520232064,
|
465
|
+
"updated": 1520299424,
|
466
|
+
"lines": [
|
467
|
+
"Git情報源",
|
468
|
+
" [https://backlog.com/ja/git-tutorial/reference/ 逆引きGit]",
|
469
|
+
" [Gitでやらかした時に使える19個の奥義 https://qiita.com/muran001/items/dea2bbbaea1260098051]",
|
470
|
+
""
|
471
|
+
]
|
472
|
+
},
|
473
|
+
{
|
474
|
+
"title": "新しい順にファイルを表示",
|
475
|
+
"created": 1520241167,
|
476
|
+
"updated": 1520241214,
|
477
|
+
"lines": [
|
478
|
+
"新しい順にファイルを表示",
|
479
|
+
"$ ファイルを新しい順に(リスト|表示)する",
|
480
|
+
"% git ls-files | xargs ls -1 -t",
|
481
|
+
""
|
482
|
+
]
|
483
|
+
},
|
484
|
+
{
|
485
|
+
"title": "タグ",
|
486
|
+
"created": 1520242919,
|
487
|
+
"updated": 1520431713,
|
488
|
+
"lines": [
|
489
|
+
"タグ",
|
490
|
+
"$ 現在使われているタグを(リスト|表示)する",
|
491
|
+
"% git tag",
|
492
|
+
"",
|
493
|
+
"$ 現在のコミットに「(#{params})」というタグを関連付けする",
|
494
|
+
"$ 「(#{params})」というタグを現在のコミットIDに関連付けする",
|
495
|
+
"% git tag #{$1}",
|
496
|
+
"",
|
497
|
+
"$ 「(#{tags})」というタグを(#{delete})",
|
498
|
+
"% git tag -d #{$1}",
|
499
|
+
"",
|
500
|
+
"$ 「(#{tags})」というタグのファイル「(#{files})」を(#{display})",
|
501
|
+
"% git show #{$1} #{$2}",
|
502
|
+
"",
|
503
|
+
"$ ファイル「(#{files})」で「(#{tags})」というタグがついてるものを(#{display})",
|
504
|
+
"% git show #{$2} #{$1}",
|
505
|
+
""
|
506
|
+
]
|
507
|
+
},
|
508
|
+
{
|
509
|
+
"title": "ブランチ名",
|
510
|
+
"created": 1520288193,
|
511
|
+
"updated": 1520288239,
|
512
|
+
"lines": [
|
513
|
+
"ブランチ名",
|
514
|
+
"% ブランチ名を(#{params})に変える",
|
515
|
+
"$ git branch -m #{$1}",
|
516
|
+
"",
|
517
|
+
"#ブランチ",
|
518
|
+
""
|
519
|
+
]
|
520
|
+
},
|
521
|
+
{
|
522
|
+
"title": "コミットをまとめる",
|
523
|
+
"created": 1520289005,
|
524
|
+
"updated": 1520300588,
|
525
|
+
"lines": [
|
526
|
+
"コミットをまとめる",
|
527
|
+
"$ (#{numbers})個前までのコミットをまとめる",
|
528
|
+
"% git rebase -i HEAD~#{$1}",
|
529
|
+
""
|
530
|
+
]
|
531
|
+
},
|
532
|
+
{
|
533
|
+
"title": "意義",
|
534
|
+
"created": 1520289678,
|
535
|
+
"updated": 1520298670,
|
536
|
+
"lines": [
|
537
|
+
"意義",
|
538
|
+
" 人間が本当にやりたいこととその実行手段の乖離をなんとかする",
|
539
|
+
" gitのコマンドは激しく複雑なのでなんとかしたい",
|
540
|
+
" という話を論文にしたいということ",
|
541
|
+
"",
|
542
|
+
"[* Contribution]",
|
543
|
+
" 現在のコンテクストに依存してヘルプを出せること",
|
544
|
+
" そういうヘルプシステムは沢山あるだろうけど",
|
545
|
+
" パラメタを指定してすぐ実行できること",
|
546
|
+
" `2` のような具体的な数字や `file`のようなファイル名などを直接指定",
|
547
|
+
" 曖昧検索できること",
|
548
|
+
" できたっけ?",
|
549
|
+
" できるようにしよう",
|
550
|
+
" 正規表現を展開するので誰でも情報を追加していける",
|
551
|
+
" 素人でも対応できるだろう",
|
552
|
+
" Wikiなので普通のデータベースとして便利なはず",
|
553
|
+
" [* 解説ページがそのままヘルプデータベースになってるみたいな]",
|
554
|
+
" ここを主張するといいかも",
|
555
|
+
" 普通に逆引きドキュメントを書いてるとヘルプシステムになってしまう",
|
556
|
+
" [* 普通はヘルプシステムと解説ドキュメントは別なので]",
|
557
|
+
" これができる関連文献は無いだろう",
|
558
|
+
"",
|
559
|
+
""
|
560
|
+
]
|
561
|
+
},
|
562
|
+
{
|
563
|
+
"title": "関連文献",
|
564
|
+
"created": 1520295677,
|
565
|
+
"updated": 1520299408,
|
566
|
+
"lines": [
|
567
|
+
"関連文献",
|
568
|
+
" [/UIPedia/Greg Little: Translating keyword commands into executable code]",
|
569
|
+
" Rob Miller, 2008",
|
570
|
+
" 「[[left margin 4 inches]]」と言うと「[[ActiveDocument.PageSetup.LeftMargin=InchesToPoints(2) ]]」を実行できる",
|
571
|
+
" ほとんど同じかもしれない?",
|
572
|
+
" [/UIPedia/Tihomir Gvero: Synthesizing Java expressions from free-form queries]",
|
573
|
+
"",
|
574
|
+
""
|
575
|
+
]
|
576
|
+
},
|
577
|
+
{
|
578
|
+
"title": "Glossary",
|
579
|
+
"created": 1520300002,
|
580
|
+
"updated": 1520393761,
|
581
|
+
"lines": [
|
582
|
+
"Glossary",
|
583
|
+
"code:glossary.rb",
|
584
|
+
" def delete; \"消す|消去する|削除する\"; end",
|
585
|
+
" def display; \"表示する|見る\"; end",
|
586
|
+
" def change; \"変更|修正\"; end",
|
587
|
+
"",
|
588
|
+
""
|
589
|
+
]
|
590
|
+
},
|
591
|
+
{
|
592
|
+
"title": "一時的に仕事を退避",
|
593
|
+
"created": 1520321191,
|
594
|
+
"updated": 1520393126,
|
595
|
+
"lines": [
|
596
|
+
"一時的に仕事を退避",
|
597
|
+
"> まだcommitしていない状態の変更ファイル(addしてる or add していない)が存在する状況で、次のコマンドを実行すると変更ファイルを退避することができる。",
|
598
|
+
"",
|
599
|
+
" $ (仕事|変更)を一時的に退避",
|
600
|
+
" % git stash save",
|
601
|
+
""
|
602
|
+
]
|
603
|
+
},
|
604
|
+
{
|
605
|
+
"title": "最近の変更を知る",
|
606
|
+
"created": 1520389238,
|
607
|
+
"updated": 1520415196,
|
608
|
+
"lines": [
|
609
|
+
"最近の変更を知る",
|
610
|
+
" $ ファイル「(#{files})」の(#{numbers})分前からの(#{change})履歴を(#{display})",
|
611
|
+
" % git log --since \"#{$2} minutes ago\" #{$1}",
|
612
|
+
" $ (#{numbers})分前からのファイル「(#{files})」の(#{change})履歴を(#{display})",
|
613
|
+
" % git log --since \"#{$1} minutes ago\" #{$2}",
|
614
|
+
" $ ファイル「(#{files})」の(#{numbers})分前からの(#{change})を(#{display})",
|
615
|
+
" % git diff HEAD \"#{$2} minutes ago\" #{$1}",
|
616
|
+
" $ (#{numbers})分前からのファイル「(#{files})」の(#{change})を(#{display})",
|
617
|
+
" % git diff HEAD \"#{$1} minutes ago\" #{$2}",
|
618
|
+
"",
|
619
|
+
" $ ファイル「(#{files})」の(#{numbers})時間前からの(#{change})履歴を(#{display})",
|
620
|
+
" % git log --since \"#{$2} hours ago\" #{$1}",
|
621
|
+
" $ (#{numbers})時間前からのファイル「(#{files})」の(#{change})履歴を(#{display})",
|
622
|
+
" % git log --since \"#{$1} hours ago\" #{$2}",
|
623
|
+
" $ ファイル「(#{files})」の(#{numbers})時間前からの(#{change})を(#{display})",
|
624
|
+
" % git diff HEAD \"#{$2} hours ago\" #{$1}",
|
625
|
+
" $ (#{numbers})時間前からのファイル「(#{files})」の(#{change})を(#{display})",
|
626
|
+
" % git diff HEAD \"#{$1} hours ago\" #{$2}",
|
627
|
+
"",
|
628
|
+
" $ ファイル「(#{files})」の(#{numbers})日前からの(#{change})履歴を(#{display})",
|
629
|
+
" % git log --since \"#{$2} days ago\" #{$1}",
|
630
|
+
" $ (#{numbers})日前からのファイル「(#{files})」の(#{change})履歴を(#{display})",
|
631
|
+
" % git log --since \"#{$1} days ago\" #{$2}",
|
632
|
+
" $ ファイル「(#{files})」の(#{numbers})日前からの(#{change})を(#{display})",
|
633
|
+
" % git diff HEAD \"#{$2} days ago\" #{$1}",
|
634
|
+
" $ (#{numbers})日前からのファイル「(#{files})」の(#{change})を(#{display})",
|
635
|
+
" % git diff HEAD \"#{$1} days ago\" #{$2}",
|
636
|
+
""
|
637
|
+
]
|
638
|
+
},
|
639
|
+
{
|
640
|
+
"title": "テンプレート",
|
641
|
+
"created": 1520393146,
|
642
|
+
"updated": 1520393200,
|
643
|
+
"lines": [
|
644
|
+
"テンプレート",
|
645
|
+
"> `$ やりたいこと`",
|
646
|
+
"> `% 実際のコマンド`",
|
647
|
+
""
|
648
|
+
]
|
649
|
+
},
|
650
|
+
{
|
651
|
+
"title": "現在の状況",
|
652
|
+
"created": 1520393428,
|
653
|
+
"updated": 1520404411,
|
654
|
+
"lines": [
|
655
|
+
"現在の状況",
|
656
|
+
"$ 現在の状況を(#{display})",
|
657
|
+
"% git status",
|
658
|
+
""
|
659
|
+
]
|
660
|
+
},
|
661
|
+
{
|
662
|
+
"title": "branches",
|
663
|
+
"created": 1520394269,
|
664
|
+
"updated": 1520404608,
|
665
|
+
"lines": [
|
666
|
+
"branches",
|
667
|
+
"code:branches.rb",
|
668
|
+
" def branches",
|
669
|
+
" list = begin",
|
670
|
+
" `git branch`.split(/\\n/)",
|
671
|
+
" rescue",
|
672
|
+
" []",
|
673
|
+
" end",
|
674
|
+
" list.collect { |entry|",
|
675
|
+
" entry.sub(/^\\s*/,'').sub(/^\\*\\s*/,'')",
|
676
|
+
" }.join(\"|\")",
|
677
|
+
" end",
|
678
|
+
"",
|
679
|
+
""
|
680
|
+
]
|
681
|
+
},
|
682
|
+
{
|
683
|
+
"title": "Reset関連",
|
684
|
+
"created": 1520413256,
|
685
|
+
"updated": 1520425254,
|
686
|
+
"lines": [
|
687
|
+
" Reset関連",
|
688
|
+
"$ 直前のコミットを取り消す",
|
689
|
+
"% git reset --soft HEAD^",
|
690
|
+
"# ファイルは変化しない",
|
691
|
+
"",
|
692
|
+
"$ ひとつ前のコミットの状態に完全に戻す",
|
693
|
+
"% git reset --hard HEAD^",
|
694
|
+
"# ファイルも変化する",
|
695
|
+
"",
|
696
|
+
"$ コミット後の変更を全部消す",
|
697
|
+
"% git reset --hard HEAD",
|
698
|
+
"",
|
699
|
+
"$ すごい昔の状態で動作を確認したい",
|
700
|
+
"% git reset --hard 昔のコミットのハッシュ値",
|
701
|
+
"",
|
702
|
+
"$ 直前のリセットをなかったことにする",
|
703
|
+
"% git reset --hard ORIG_HEAD",
|
704
|
+
"",
|
705
|
+
"$ 過去のあらゆる操作履歴を見る",
|
706
|
+
"% git reflog",
|
707
|
+
"",
|
708
|
+
"$ 過去のコミット履歴を見る",
|
709
|
+
"% git log",
|
710
|
+
""
|
711
|
+
]
|
712
|
+
},
|
713
|
+
{
|
714
|
+
"title": "古いバージョンに一時的に戻す",
|
715
|
+
"created": 1520414345,
|
716
|
+
"updated": 1520414508,
|
717
|
+
"lines": [
|
718
|
+
"古いバージョンに一時的に戻す",
|
719
|
+
"$ (#{numbers})日前の状態に一時的に戻す",
|
720
|
+
"% git checkout \"@{#{$1} days ago}\" ",
|
721
|
+
"",
|
722
|
+
"$ (#{numbers})時間前の状態に一時的に戻す",
|
723
|
+
"% git checkout \"@{#{$1} hours ago}\" ",
|
724
|
+
"",
|
725
|
+
"$ (#{numbers})分前の状態に一時的に戻す",
|
726
|
+
"% git checkout \"@{#{$1} mins ago}\" ",
|
727
|
+
""
|
728
|
+
]
|
729
|
+
},
|
730
|
+
{
|
731
|
+
"title": "タグリスト",
|
732
|
+
"created": 1520429556,
|
733
|
+
"updated": 1520430675,
|
734
|
+
"lines": [
|
735
|
+
"タグリスト",
|
736
|
+
"code:tags.rb",
|
737
|
+
" def tags",
|
738
|
+
" tags = begin",
|
739
|
+
" `git tag`.split(/\\n/)",
|
740
|
+
" rescue",
|
741
|
+
" []",
|
742
|
+
" end",
|
743
|
+
" tags.join(\"|\")",
|
744
|
+
" end",
|
745
|
+
"",
|
746
|
+
"#タグ",
|
747
|
+
""
|
748
|
+
]
|
749
|
+
}
|
750
|
+
]
|
751
|
+
}
|
data/exe/githelp
CHANGED
@@ -1,63 +1,171 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- ruby -*-
|
2
3
|
|
3
|
-
require '
|
4
|
+
require 'net/https'
|
5
|
+
require 'json'
|
6
|
+
require 'uri'
|
7
|
+
require 'cgi'
|
8
|
+
require 'optparse'
|
9
|
+
require 're_expand'
|
4
10
|
|
5
|
-
|
11
|
+
class GitHelp
|
12
|
+
def datafile
|
13
|
+
File.expand_path("~/.githelp")
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@pagedata = {}
|
18
|
+
end
|
6
19
|
|
7
|
-
|
8
|
-
|
20
|
+
def getsbdata(api)
|
21
|
+
uri = URI.parse("https://scrapbox.io/api#{api}")
|
22
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
23
|
+
http.use_ssl = true
|
24
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
25
|
+
req = Net::HTTP::Get.new(uri.path)
|
26
|
+
res = http.request(req)
|
27
|
+
res.body.force_encoding("utf-8")
|
28
|
+
end
|
29
|
+
|
30
|
+
# ページタイトルのリストを取得
|
31
|
+
def gettitles
|
32
|
+
data = getsbdata("/pages/GitHelp")
|
33
|
+
JSON.parse(data)['pages'].collect { |page|
|
34
|
+
page['title']
|
35
|
+
}
|
36
|
+
end
|
9
37
|
|
10
|
-
|
38
|
+
# それぞれのページに対して処理
|
39
|
+
def getpage(title)
|
40
|
+
text = getsbdata("/pages/GitHelp/#{URI.encode(title).gsub(/\//,'%2f')}/text")
|
41
|
+
@pagedata[title] = text.split(/\n/)
|
42
|
+
end
|
11
43
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
44
|
+
def getdata
|
45
|
+
#
|
46
|
+
# ページデータ取得
|
47
|
+
#
|
48
|
+
puts "-----------------ページデータを取得"
|
49
|
+
gettitles.each { |title|
|
50
|
+
puts "...#{title}"
|
51
|
+
getpage title
|
52
|
+
}
|
17
53
|
|
54
|
+
dumpdata = {}
|
55
|
+
dumpdata['codes'] = []
|
56
|
+
dumpdata['defs'] = []
|
57
|
+
|
58
|
+
#
|
59
|
+
# 関数/定数を評価"
|
60
|
+
#
|
61
|
+
puts "-----------------関数/定数を取得"
|
62
|
+
@pagedata.each { |title,pagedata|
|
63
|
+
puts "...#{title}"
|
64
|
+
pagedata. each { |line|
|
65
|
+
if line =~ /code:(.*)\.rb$/ then
|
66
|
+
puts "=========== #{$1}.rb"
|
67
|
+
text = getsbdata("/code/GitHelp/#{URI.encode(title)}/#{$1}.rb")
|
68
|
+
dumpdata['codes'] << text
|
69
|
+
end
|
70
|
+
}
|
71
|
+
}
|
72
|
+
puts "-----------------GitHelpデータを検出"
|
73
|
+
@pagedata.each { |title,pagedata|
|
74
|
+
puts "...#{title}"
|
75
|
+
pagedata.each { |line|
|
76
|
+
if line =~ /^\s*[\$\%]/
|
77
|
+
puts line
|
78
|
+
# line.force_encoding("utf-8")
|
79
|
+
dumpdata['defs'] << line
|
80
|
+
end
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
File.open(datafile,"w"){ |f|
|
85
|
+
f.puts dumpdata.to_json
|
86
|
+
}
|
87
|
+
end
|
18
88
|
|
19
|
-
|
89
|
+
def githelp(pager)
|
90
|
+
data = JSON.parse(File.read(datafile))
|
20
91
|
|
21
|
-
#
|
22
|
-
# 関数定義などをeval
|
23
|
-
#
|
24
|
-
data['codes'].each { |code|
|
25
|
-
|
26
|
-
}
|
92
|
+
#
|
93
|
+
# 関数定義などをeval
|
94
|
+
#
|
95
|
+
data['codes'].each { |code|
|
96
|
+
eval code
|
97
|
+
}
|
27
98
|
|
28
|
-
g = ExpandRuby::Generator.new # re_expandのジェネレータ
|
99
|
+
g = ExpandRuby::Generator.new # re_expandのジェネレータ
|
29
100
|
|
30
|
-
#
|
31
|
-
# GitHelpエントリ
|
32
|
-
#
|
33
|
-
lines = []
|
101
|
+
#
|
102
|
+
# GitHelpエントリ
|
103
|
+
#
|
104
|
+
lines = []
|
105
|
+
data['defs'].each { |line|
|
106
|
+
if line =~ /^\s*\$\s*(.*)$/ # $....
|
107
|
+
lines << $1
|
108
|
+
elsif line =~ /^\s*\%\s*(.*)$/ # %....
|
109
|
+
cmd = $1
|
110
|
+
lines.each { |l|
|
111
|
+
desc = eval('"' + l + '"')
|
112
|
+
g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8')
|
113
|
+
}
|
114
|
+
lines = []
|
115
|
+
end
|
116
|
+
}
|
34
117
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
118
|
+
res = g.generate " #{ARGV.join(' ')} "
|
119
|
+
|
120
|
+
listed = {}
|
121
|
+
list = res[0].find_all { |a| # 0 ambig
|
122
|
+
if listed[a[1]]
|
123
|
+
false
|
124
|
+
else
|
125
|
+
listed[a[1]] = true
|
126
|
+
end
|
43
127
|
}
|
44
|
-
|
128
|
+
|
129
|
+
if pager == 'peco' then
|
130
|
+
res = IO.popen(pager, "r+") {|io|
|
131
|
+
list.each_with_index { |entry,ind|
|
132
|
+
io.puts "#[#{ind}] #{entry[0]}"
|
133
|
+
io.puts " #{entry[1]}"
|
134
|
+
}
|
135
|
+
io.close_write
|
136
|
+
io.gets
|
137
|
+
}
|
138
|
+
cmd = res.sub(/^\s*/,'')
|
139
|
+
puts cmd
|
140
|
+
system cmd
|
141
|
+
else
|
142
|
+
res = IO.popen(pager, "w") {|io|
|
143
|
+
list.each_with_index { |entry,ind|
|
144
|
+
io.puts "#[#{ind}] #{entry[0]}"
|
145
|
+
io.puts " #{entry[1]}"
|
146
|
+
}
|
147
|
+
}
|
148
|
+
end
|
45
149
|
end
|
46
|
-
}
|
47
150
|
|
48
|
-
|
151
|
+
end
|
49
152
|
|
50
|
-
|
51
|
-
list = res[0].find_all { |a| # 0 ambig
|
52
|
-
if listed[a[1]]
|
53
|
-
false
|
54
|
-
else
|
55
|
-
listed[a[1]] = true
|
56
|
-
end
|
57
|
-
}
|
153
|
+
options = ARGV.getopts('ut')
|
58
154
|
|
59
|
-
|
60
|
-
puts "#[#{ind}] #{entry[0]}"
|
61
|
-
puts " #{entry[1]}"
|
62
|
-
}
|
155
|
+
githelp = GitHelp.new
|
63
156
|
|
157
|
+
if !File.exist?(githelp.datafile) && !options['u']
|
158
|
+
puts "#{githelp.datafile}を作成します..."
|
159
|
+
githelp.getdata
|
160
|
+
end
|
161
|
+
|
162
|
+
if options['u'] then
|
163
|
+
githelp.getdata
|
164
|
+
else
|
165
|
+
pager = 'peco'
|
166
|
+
peco_installed = system "command -v peco > /dev/null"
|
167
|
+
if options['t'] || !peco_installed
|
168
|
+
pager = 'more'
|
169
|
+
end
|
170
|
+
githelp.githelp pager
|
171
|
+
end
|
data/lib/githelp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: githelp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshiyuki Masui
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,8 +70,6 @@ description: GitHelp - lists git commands from user's vague query strings
|
|
70
70
|
email:
|
71
71
|
- masui@pitecan.com
|
72
72
|
executables:
|
73
|
-
- getghdata
|
74
|
-
- gh
|
75
73
|
- githelp
|
76
74
|
extensions: []
|
77
75
|
extra_rdoc_files: []
|
@@ -83,12 +81,9 @@ files:
|
|
83
81
|
- Makefile
|
84
82
|
- README.md
|
85
83
|
- Rakefile
|
84
|
+
- backups/GitHelp.json
|
86
85
|
- bin/gh
|
87
|
-
- exe/getghdata
|
88
|
-
- exe/gh
|
89
86
|
- exe/githelp
|
90
|
-
- getdata
|
91
|
-
- githelp
|
92
87
|
- githelp.gemspec
|
93
88
|
- lib/githelp.rb
|
94
89
|
- lib/githelp/version.rb
|
data/exe/getghdata
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'net/https'
|
5
|
-
require 'json'
|
6
|
-
require 'uri'
|
7
|
-
require 'cgi'
|
8
|
-
require 'json'
|
9
|
-
|
10
|
-
class GitHelp
|
11
|
-
DATAFILE = File.expand_path("~/.githelp")
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@pagedata = {}
|
15
|
-
end
|
16
|
-
|
17
|
-
# ページタイトルのリストを取得
|
18
|
-
def gettitles
|
19
|
-
uri = URI.parse("https://scrapbox.io/api/pages/GitHelp")
|
20
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
21
|
-
http.use_ssl = true
|
22
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
23
|
-
req = Net::HTTP::Get.new(uri.path)
|
24
|
-
res = http.request(req)
|
25
|
-
JSON.parse(res.body)['pages'].collect { |page|
|
26
|
-
page['title']
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
# それぞれのページに対して処理
|
31
|
-
def getpage(title)
|
32
|
-
puts title
|
33
|
-
uri = URI.parse("https://scrapbox.io/api/pages/GitHelp/#{URI.encode(title).gsub(/\//,'%2f')}/text") # a/b みたいなタイトルのとき困る
|
34
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
35
|
-
http.use_ssl = true
|
36
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
37
|
-
req = Net::HTTP::Get.new(uri.path)
|
38
|
-
res = http.request(req)
|
39
|
-
text = res.body
|
40
|
-
text.force_encoding("utf-8")
|
41
|
-
# puts text
|
42
|
-
# @pagedata[title] = CGI.unescape(text).split(/\n/)
|
43
|
-
@pagedata[title] = text.split(/\n/)
|
44
|
-
end
|
45
|
-
|
46
|
-
def process
|
47
|
-
#
|
48
|
-
# ページデータ取得
|
49
|
-
#
|
50
|
-
gettitles.each { |title|
|
51
|
-
getpage title
|
52
|
-
}
|
53
|
-
|
54
|
-
dumpdata = {}
|
55
|
-
dumpdata['codes'] = []
|
56
|
-
dumpdata['defs'] = []
|
57
|
-
|
58
|
-
#
|
59
|
-
# 関数/定数を評価"
|
60
|
-
#
|
61
|
-
puts "-----------------関数/定数を取得"
|
62
|
-
@pagedata.each { |title,pagedata|
|
63
|
-
puts title
|
64
|
-
pagedata. each { |line|
|
65
|
-
if line =~ /code:(.*)\.rb$/ then
|
66
|
-
puts "==========="
|
67
|
-
uri = URI.parse("https://scrapbox.io/api/code/GitHelp/#{URI.encode(title)}/#{$1}.rb")
|
68
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
69
|
-
http.use_ssl = true
|
70
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
71
|
-
req = Net::HTTP::Get.new(uri.path)
|
72
|
-
res = http.request(req)
|
73
|
-
# puts CGI.unescape(res.body)
|
74
|
-
text = res.body
|
75
|
-
text.force_encoding('utf-8')
|
76
|
-
dumpdata['codes'] << text
|
77
|
-
end
|
78
|
-
}
|
79
|
-
}
|
80
|
-
puts "-----------------GitHelpデータを検出"
|
81
|
-
@pagedata.each { |title,pagedata|
|
82
|
-
puts "...#{title}"
|
83
|
-
pagedata.each { |line|
|
84
|
-
puts line
|
85
|
-
if line =~ /^\s*[\$\%]/
|
86
|
-
puts line
|
87
|
-
line.force_encoding("utf-8")
|
88
|
-
dumpdata['defs'] << line
|
89
|
-
end
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
File.open(DATAFILE,"w"){ |f|
|
94
|
-
f.puts dumpdata.to_json
|
95
|
-
}
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
githelp = GitHelp.new
|
100
|
-
githelp.process
|
data/exe/gh
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
have_peco = system "command -v peco > /dev/null"
|
3
|
-
|
4
|
-
if have_peco
|
5
|
-
# system "eval `githelp #{$*.join(' ')} | peco`"
|
6
|
-
cmd = `githelp #{$*.join(' ')} | peco`.gsub(/^\s*/,'')
|
7
|
-
puts cmd
|
8
|
-
system cmd
|
9
|
-
else
|
10
|
-
puts "pecoをインストールして下さい"
|
11
|
-
end
|
data/getdata
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'net/https'
|
5
|
-
require 'json'
|
6
|
-
require 'uri'
|
7
|
-
require 'cgi'
|
8
|
-
require 'json'
|
9
|
-
|
10
|
-
class GitHelp
|
11
|
-
DATAFILE = File.expand_path("~/.githelp")
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@pagedata = {}
|
15
|
-
end
|
16
|
-
|
17
|
-
# ページタイトルのリストを取得
|
18
|
-
def gettitles
|
19
|
-
uri = URI.parse("https://scrapbox.io/api/pages/GitHelp")
|
20
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
21
|
-
http.use_ssl = true
|
22
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
23
|
-
req = Net::HTTP::Get.new(uri.path)
|
24
|
-
res = http.request(req)
|
25
|
-
JSON.parse(res.body)['pages'].collect { |page|
|
26
|
-
page['title']
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
# それぞれのページに対して処理
|
31
|
-
def getpage(title)
|
32
|
-
puts title
|
33
|
-
uri = URI.parse("https://scrapbox.io/api/pages/GitHelp/#{URI.encode(title).gsub(/\//,'%2f')}/text") # a/b みたいなタイトルのとき困る
|
34
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
35
|
-
http.use_ssl = true
|
36
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
37
|
-
req = Net::HTTP::Get.new(uri.path)
|
38
|
-
res = http.request(req)
|
39
|
-
text = res.body
|
40
|
-
text.force_encoding("utf-8")
|
41
|
-
# puts text
|
42
|
-
# @pagedata[title] = CGI.unescape(text).split(/\n/)
|
43
|
-
@pagedata[title] = text.split(/\n/)
|
44
|
-
end
|
45
|
-
|
46
|
-
def process
|
47
|
-
#
|
48
|
-
# ページデータ取得
|
49
|
-
#
|
50
|
-
gettitles.each { |title|
|
51
|
-
getpage title
|
52
|
-
}
|
53
|
-
|
54
|
-
dumpdata = {}
|
55
|
-
dumpdata['codes'] = []
|
56
|
-
dumpdata['defs'] = []
|
57
|
-
|
58
|
-
#
|
59
|
-
# 関数/定数を評価"
|
60
|
-
#
|
61
|
-
puts "-----------------関数/定数を取得"
|
62
|
-
@pagedata.each { |title,pagedata|
|
63
|
-
puts title
|
64
|
-
pagedata. each { |line|
|
65
|
-
if line =~ /code:(.*)\.rb$/ then
|
66
|
-
puts "==========="
|
67
|
-
uri = URI.parse("https://scrapbox.io/api/code/GitHelp/#{URI.encode(title)}/#{$1}.rb")
|
68
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
69
|
-
http.use_ssl = true
|
70
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
71
|
-
req = Net::HTTP::Get.new(uri.path)
|
72
|
-
res = http.request(req)
|
73
|
-
# puts CGI.unescape(res.body)
|
74
|
-
text = res.body
|
75
|
-
text.force_encoding('utf-8')
|
76
|
-
dumpdata['codes'] << text
|
77
|
-
end
|
78
|
-
}
|
79
|
-
}
|
80
|
-
puts "-----------------GitHelpデータを検出"
|
81
|
-
@pagedata.each { |title,pagedata|
|
82
|
-
puts "...#{title}"
|
83
|
-
pagedata.each { |line|
|
84
|
-
puts line
|
85
|
-
if line =~ /^\s*[\$\%]/
|
86
|
-
puts line
|
87
|
-
line.force_encoding("utf-8")
|
88
|
-
dumpdata['defs'] << line
|
89
|
-
end
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
File.open(DATAFILE,"w"){ |f|
|
94
|
-
f.puts dumpdata.to_json
|
95
|
-
}
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
githelp = GitHelp.new
|
100
|
-
githelp.process
|
data/githelp
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 're_expand'
|
4
|
-
|
5
|
-
#require '/Users/masui/expand_ruby/lib/re_expand.rb'
|
6
|
-
#require '/Users/masui/expand_ruby/lib/re_expand/Generator'
|
7
|
-
#require '/Users/masui/expand_ruby/lib/re_expand/Node'
|
8
|
-
#require '/Users/masui/expand_ruby/lib/re_expand/Scanner'
|
9
|
-
|
10
|
-
require 'json'
|
11
|
-
|
12
|
-
DATAFILE = File.expand_path("~/.githelp")
|
13
|
-
|
14
|
-
data = JSON.parse(File.read(DATAFILE))
|
15
|
-
|
16
|
-
#
|
17
|
-
# 関数定義などをeval
|
18
|
-
#
|
19
|
-
data['codes'].each { |code|
|
20
|
-
eval code
|
21
|
-
}
|
22
|
-
|
23
|
-
g = ExpandRuby::Generator.new # re_expandのジェネレータ
|
24
|
-
|
25
|
-
#
|
26
|
-
# GitHelpエントリ
|
27
|
-
#
|
28
|
-
lines = []
|
29
|
-
|
30
|
-
data['defs'].each { |line|
|
31
|
-
if line =~ /^\s*\$\s*(.*)$/ # $....
|
32
|
-
lines << $1
|
33
|
-
elsif line =~ /^\s*\%\s*(.*)$/ # %....
|
34
|
-
cmd = $1
|
35
|
-
lines.each { |l|
|
36
|
-
desc = eval('"' + l + '"')
|
37
|
-
g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8')
|
38
|
-
}
|
39
|
-
lines = []
|
40
|
-
end
|
41
|
-
}
|
42
|
-
|
43
|
-
res = g.generate " #{args.join(' ')} "
|
44
|
-
|
45
|
-
listed = {}
|
46
|
-
list = res[0].find_all { |a| # 0 ambig
|
47
|
-
if listed[a[1]]
|
48
|
-
false
|
49
|
-
else
|
50
|
-
listed[a[1]] = true
|
51
|
-
end
|
52
|
-
}
|
53
|
-
|
54
|
-
list.each_with_index { |entry,ind|
|
55
|
-
puts "#[#{ind}] #{entry[0]}"
|
56
|
-
puts " #{entry[1]}"
|
57
|
-
}
|