aboutsummaryrefslogtreecommitdiff
path: root/po/eo/LC_MESSAGES/_tils/2020-08-28-grep-online-repositories.po
blob: a339bb62b873bebe5048fb7bc0573f4198346b7a (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#
msgid ""
msgstr ""

msgid ""
"I often find interesting source code repositories online that I want to grep"
" for some pattern but I can't, because either:"
msgstr ""

msgid ""
"the repository is on [cgit](https://git.zx2c4.com/cgit/) or a similar code "
"repository that doesn't allow search in files, or;"
msgstr ""

msgid ""
"the search function is really bad, and doesn't allow me to use regular "
"expressions for searching patterns in the code."
msgstr ""

msgid ""
"Here's a simple script that allows you to overcome that problem easily:"
msgstr ""

msgid ""
"It is a wrapper around `git grep` that downloads the repository when "
"missing. Save in a file called `git-search`, make the file executable and "
"add it to your path."
msgstr ""

msgid "Overview:"
msgstr ""

msgid "*lines 1~2*:"
msgstr ""

msgid ""
"Bash shebang and the `set -eu` options to exit on error or undefined "
"variables."
msgstr ""

msgid "*lines 4~30*:"
msgstr ""

msgid "Usage text to be printed when providing less arguments than expected."
msgstr ""

msgid "*line 33*:"
msgstr ""

msgid "Extract the repository name from the URL, removing trailing slashes."
msgstr ""

msgid "*lines 34~37*:"
msgstr ""

msgid "Download the repository when missing and go to the folder."
msgstr ""

msgid "*line 39*:"
msgstr ""

msgid "Make the variable `$@` contain the rest of the unused arguments."
msgstr ""

msgid "*line 40*:"
msgstr ""

msgid "Perform `git grep`, forwarding the remaining arguments from `$@`."
msgstr ""

msgid "Example output:"
msgstr ""

msgid ""
"Subsequent greps on the same repository are faster because no download is "
"needed."
msgstr ""

msgid "When no argument is provided, it prints the usage text:"
msgstr ""

msgid ""
"#!/usr/bin/env bash\n"
"set -eu\n"
"\n"
"end=\"\\033[0m\"\n"
"red=\"\\033[0;31m\"\n"
"red() { echo -e \"${red}${1}${end}\"; }\n"
"\n"
"usage() {\n"
"  red \"Missing argument $1.\\n\"\n"
"  cat <<EOF\n"
"Usage:\n"
"    $0 <REGEX_PATTERN> <REPOSITORY_URL>\n"
"\n"
"      Arguments:\n"
"        REGEX_PATTERN     Regular expression that \"git grep\" can search\n"
"        REPOSITORY_URL    URL address that \"git clone\" can download the repository from\n"
"\n"
"Examples:\n"
"    Searching \"make get-git\" in cgit repository:\n"
"        git search 'make get-git' https://git.zx2c4.com/cgit/\n"
"        git search 'make get-git' https://git.zx2c4.com/cgit/ -- \\$(git rev-list --all)\n"
"EOF\n"
"  exit 2\n"
"}\n"
"\n"
"\n"
"REGEX_PATTERN=\"${1:-}\"\n"
"REPOSITORY_URL=\"${2:-}\"\n"
"[[ -z \"${REGEX_PATTERN}\" ]] && usage 'REGEX_PATTERN'\n"
"[[ -z \"${REPOSITORY_URL}\" ]] && usage 'REPOSITORY_URL'\n"
"\n"
"mkdir -p /tmp/git-search\n"
"DIRNAME=\"$(echo \"${REPOSITORY_URL%/}\" | rev | cut -d/ -f1 | rev)\"\n"
"if [[ ! -d \"/tmp/git-search/${DIRNAME}\" ]]; then\n"
"  git clone \"${REPOSITORY_URL}\" \"/tmp/git-search/${DIRNAME}\"\n"
"fi\n"
"pushd \"/tmp/git-search/${DIRNAME}\"\n"
"\n"
"shift 3 || shift 2 # when \"--\" is missing\n"
"git grep \"${REGEX_PATTERN}\" \"${@}\"\n"
msgstr ""

msgid ""
"$ git search 'make get-git' https://git.zx2c4.com/cgit/\n"
"Clonage dans '/tmp/git-search/cgit'...\n"
"remote: Enumerating objects: 542, done.\n"
"remote: Counting objects: 100% (542/542), done.\n"
"remote: Compressing objects: 100% (101/101), done.\n"
"warning: object 51dd1eff1edc663674df9ab85d2786a40f7ae3a5: gitmodulesParse: could not parse gitmodules blob\n"
"remote: Total 7063 (delta 496), reused 446 (delta 441), pack-reused 6521\n"
"Réception d'objets: 100% (7063/7063), 8.69 Mio | 5.39 Mio/s, fait.\n"
"Résolution des deltas: 100% (5047/5047), fait.\n"
"/tmp/git-search/cgit ~/dev/libre/songbooks/docs\n"
"README:    $ make get-git\n"
"\n"
"$ git search 'make get-git' https://git.zx2c4.com/cgit/\n"
"/tmp/git-search/cgit ~/dev/libre/songbooks/docs\n"
"README:    $ make get-git\n"
msgstr ""

msgid ""
"$ git search\n"
"Missing argument REGEX_PATTERN.\n"
"\n"
"Usage:\n"
"    /home/andreh/dev/libre/dotfiles/scripts/ad-hoc/git-search <REGEX_PATTERN> <REPOSITORY_URL>\n"
"\n"
"      Arguments:\n"
"        REGEX_PATTERN     Regular expression that \"git grep\" can search\n"
"        REPOSITORY_URL    URL address that \"git clone\" can download the repository from\n"
"\n"
"Examples:\n"
"    Searching \"make get-git\" in cgit repository:\n"
"        git search 'make get-git' https://git.zx2c4.com/cgit/\n"
"        git search 'make get-git' https://git.zx2c4.com/cgit/ -- $(git rev-list --all)\n"
msgstr ""

msgid "title: Grep online repositories"
msgstr ""

msgid "date: 2020-08-28"
msgstr ""

msgid "layout: post"
msgstr ""

msgid "lang: en"
msgstr ""

msgid "ref: grep-online-repositories"
msgstr ""

msgid "eu_categories: git"
msgstr ""

#~ msgid ""
#~ "title: Grep online repositories\n"
#~ "date: 2020-08-28\n"
#~ "layout: post\n"
#~ "lang: en\n"
#~ "ref: grep-online-repositories"
#~ msgstr ""