git-well 0.2.3__tar.gz → 0.2.4__tar.gz
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.
- git_well-0.2.4/MANIFEST.in +1 -0
- {git_well-0.2.3 → git_well-0.2.4}/PKG-INFO +14 -2
- {git_well-0.2.3 → git_well-0.2.4}/git_well/__init__.py +1 -1
- git_well-0.2.4/git_well/_utils.py +262 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/demo/__init__.py +23 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_autoconf_gpgsign.py +5 -1
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_discover_remote.py +1 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_remote_protocol.py +1 -110
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_squash_streaks.py +1 -1
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_sync.py +7 -2
- git_well-0.2.4/git_well/git_url_components.py +66 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/main.py +1 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well.egg-info/PKG-INFO +14 -2
- {git_well-0.2.3 → git_well-0.2.4}/git_well.egg-info/SOURCES.txt +6 -0
- git_well-0.2.4/requirements/docs.txt +8 -0
- git_well-0.2.4/requirements/optional.txt +5 -0
- git_well-0.2.4/requirements/runtime.txt +13 -0
- git_well-0.2.4/requirements/tests.txt +37 -0
- {git_well-0.2.3 → git_well-0.2.4}/setup.py +5 -4
- git_well-0.2.3/git_well/_utils.py +0 -115
- {git_well-0.2.3 → git_well-0.2.4}/README.rst +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/__main__.py +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/__main__.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/_utils.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_autoconf_gpgsign.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_branch_cleanup.py +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_branch_cleanup.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_branch_upgrade.py +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_branch_upgrade.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_discover_remote.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_rebase_add_continue.py +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_rebase_add_continue.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_remote_protocol.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_squash_streaks.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_stats.py +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_stats.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_sync.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_track_upstream.py +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/git_track_upstream.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/main.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/py.typed +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/repo.py +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well/repo.pyi +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well.egg-info/dependency_links.txt +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well.egg-info/entry_points.txt +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well.egg-info/requires.txt +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/git_well.egg-info/top_level.txt +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/pyproject.toml +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/setup.cfg +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/tests/test_cli.py +0 -0
- {git_well-0.2.3 → git_well-0.2.4}/tests/test_import.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include requirements/*.txt
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: git_well
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: The git_well module
|
|
5
5
|
Home-page: https://github.com/Erotemic/git_well
|
|
6
6
|
Author: Jon Crall
|
|
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
21
|
Requires-Python: >=3.7
|
|
21
22
|
Description-Content-Type: text/x-rst
|
|
22
23
|
Requires-Dist: ubelt>=1.3.3
|
|
@@ -187,6 +188,17 @@ Requires-Dist: sphinx-autoapi==1.8.4; extra == "docs-strict"
|
|
|
187
188
|
Requires-Dist: Pygments==2.9.0; extra == "docs-strict"
|
|
188
189
|
Requires-Dist: myst_parser==0.18.0; extra == "docs-strict"
|
|
189
190
|
Requires-Dist: sphinx-reredirects==0.0.1; extra == "docs-strict"
|
|
191
|
+
Dynamic: author
|
|
192
|
+
Dynamic: author-email
|
|
193
|
+
Dynamic: classifier
|
|
194
|
+
Dynamic: description
|
|
195
|
+
Dynamic: description-content-type
|
|
196
|
+
Dynamic: home-page
|
|
197
|
+
Dynamic: license
|
|
198
|
+
Dynamic: provides-extra
|
|
199
|
+
Dynamic: requires-dist
|
|
200
|
+
Dynamic: requires-python
|
|
201
|
+
Dynamic: summary
|
|
190
202
|
|
|
191
203
|
The git_well Module
|
|
192
204
|
===================
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import ubelt as ub
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def rich_print(*args, **kwargs):
|
|
5
|
+
try:
|
|
6
|
+
from rich import print as print_
|
|
7
|
+
except Exception:
|
|
8
|
+
print_ = print
|
|
9
|
+
return print_(*args, **kwargs)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def find_merged_branches(repo, main_branch='main'):
|
|
13
|
+
# git branch --merged main
|
|
14
|
+
# main_branch = 'main'
|
|
15
|
+
merged_branches = [p.replace('*', '').strip() for p in repo.git.branch(merged=main_branch).split('\n') if p.strip()]
|
|
16
|
+
merged_branches = ub.oset(merged_branches) - {main_branch}
|
|
17
|
+
return merged_branches
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def confirm(msg):
|
|
21
|
+
try:
|
|
22
|
+
from rich import prompt
|
|
23
|
+
ret = prompt.Confirm.ask(msg)
|
|
24
|
+
except ImportError:
|
|
25
|
+
while True:
|
|
26
|
+
ans = input(msg + ' [y/n]')
|
|
27
|
+
if ans in {'y', 'yes'}:
|
|
28
|
+
ret = True
|
|
29
|
+
break
|
|
30
|
+
elif ans in {'n', 'no'}:
|
|
31
|
+
ret = False
|
|
32
|
+
break
|
|
33
|
+
else:
|
|
34
|
+
print('invalid response')
|
|
35
|
+
return ret
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def choice_prompt(msg, choices):
|
|
39
|
+
"""
|
|
40
|
+
Ignore:
|
|
41
|
+
choice_prompt('which one?', choices=['a', 'b', 'c'])
|
|
42
|
+
"""
|
|
43
|
+
try:
|
|
44
|
+
from rich.prompt import Prompt, InvalidResponse
|
|
45
|
+
except ImportError:
|
|
46
|
+
print('Rich is required here')
|
|
47
|
+
raise
|
|
48
|
+
|
|
49
|
+
class ChoiceWithIntPrompt(Prompt):
|
|
50
|
+
"""
|
|
51
|
+
Assigns an integer to each choice.
|
|
52
|
+
"""
|
|
53
|
+
def make_prompt(self, default):
|
|
54
|
+
prompt = self.prompt.copy()
|
|
55
|
+
prompt.end = ""
|
|
56
|
+
|
|
57
|
+
if self.show_choices and self.choices:
|
|
58
|
+
prompt.append('\n')
|
|
59
|
+
for idx, choice in enumerate(self.choices, start=1):
|
|
60
|
+
try:
|
|
61
|
+
int(choice)
|
|
62
|
+
except ValueError:
|
|
63
|
+
...
|
|
64
|
+
else:
|
|
65
|
+
raise AssertionError('choices cannot be integers')
|
|
66
|
+
|
|
67
|
+
prompt.append(f'{idx}. ', style='json.number')
|
|
68
|
+
prompt.append(f'{choice}\n', style="prompt")
|
|
69
|
+
if (
|
|
70
|
+
default != ...
|
|
71
|
+
and self.show_default
|
|
72
|
+
and isinstance(default, (str, self.response_type))
|
|
73
|
+
):
|
|
74
|
+
prompt.append(" ")
|
|
75
|
+
_default = self.render_default(default)
|
|
76
|
+
prompt.append(_default)
|
|
77
|
+
|
|
78
|
+
prompt.append(self.prompt_suffix)
|
|
79
|
+
return prompt
|
|
80
|
+
|
|
81
|
+
def process_response(self, value: str):
|
|
82
|
+
value = value.strip()
|
|
83
|
+
assert self.choices is not None
|
|
84
|
+
try:
|
|
85
|
+
return_value = self.response_type(value)
|
|
86
|
+
except ValueError:
|
|
87
|
+
raise InvalidResponse(self.validate_error_message)
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
idx = int(return_value) - 1
|
|
91
|
+
return_value = self.choices[idx]
|
|
92
|
+
except Exception:
|
|
93
|
+
...
|
|
94
|
+
|
|
95
|
+
if return_value not in self.choices:
|
|
96
|
+
raise InvalidResponse(self.illegal_choice_message)
|
|
97
|
+
|
|
98
|
+
return return_value
|
|
99
|
+
|
|
100
|
+
return ChoiceWithIntPrompt.ask(msg, choices=choices)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def find_git_root(dpath):
|
|
104
|
+
cwd = ub.Path(dpath).absolute()
|
|
105
|
+
parts = cwd.parts
|
|
106
|
+
found = None
|
|
107
|
+
for i in reversed(range(0, len(parts) + 1)):
|
|
108
|
+
p = ub.Path(*parts[0:i])
|
|
109
|
+
cand = p / '.git'
|
|
110
|
+
if cand.exists():
|
|
111
|
+
found = p
|
|
112
|
+
break
|
|
113
|
+
if found is None:
|
|
114
|
+
raise Exception('cannot find git root')
|
|
115
|
+
return found
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class GitURL(str):
|
|
119
|
+
"""
|
|
120
|
+
Represents a url to a git repo and can parse info about / modify the
|
|
121
|
+
protocol
|
|
122
|
+
|
|
123
|
+
References:
|
|
124
|
+
https://git-scm.com/docs/git-clone#_git_urls
|
|
125
|
+
|
|
126
|
+
CommandLine:
|
|
127
|
+
xdoctest -m git_well.git_remote_protocol GitURL
|
|
128
|
+
|
|
129
|
+
Example:
|
|
130
|
+
>>> from git_well.git_remote_protocol import * # NOQA
|
|
131
|
+
>>> from git_well._utils import * # NOQA
|
|
132
|
+
>>> urls = [
|
|
133
|
+
>>> GitURL('https://foo.bar/user/repo.git'),
|
|
134
|
+
>>> GitURL('ssh://foo.bar/user/repo.git'),
|
|
135
|
+
>>> GitURL('ssh://git@foo.bar/user/repo.git'),
|
|
136
|
+
>>> GitURL('git@foo.bar:group/repo.git'),
|
|
137
|
+
>>> GitURL('host:path/to/my/repo/.git'),
|
|
138
|
+
>>> ]
|
|
139
|
+
>>> for url in urls:
|
|
140
|
+
>>> info = url.info
|
|
141
|
+
>>> print('---')
|
|
142
|
+
>>> print(f'url = {url}')
|
|
143
|
+
>>> print(ub.urepr(info))
|
|
144
|
+
>>> print('As git : ' + url.to_git())
|
|
145
|
+
>>> print('As ssh : ' + url.to_ssh())
|
|
146
|
+
>>> print('As https : ' + url.to_https())
|
|
147
|
+
>>> if info['protocol'] not in {'scp'}:
|
|
148
|
+
>>> # SCP recon is broken
|
|
149
|
+
>>> recon = url.to_protocol(info['protocol'])
|
|
150
|
+
>>> assert recon == url
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
def __init__(self, data):
|
|
154
|
+
# note: inheriting from str so data is handled in __new__
|
|
155
|
+
self._info = None
|
|
156
|
+
|
|
157
|
+
def _parse(self):
|
|
158
|
+
import parse
|
|
159
|
+
parse.Parser('ssh://{user}')
|
|
160
|
+
|
|
161
|
+
def _fixup_endpoint(self, repo_endpoint):
|
|
162
|
+
if repo_endpoint.endswith('.git'):
|
|
163
|
+
repo_name = repo_endpoint[:-4]
|
|
164
|
+
else:
|
|
165
|
+
repo_name = repo_endpoint
|
|
166
|
+
repo_endpoint = repo_name + '.git'
|
|
167
|
+
return repo_name, repo_endpoint
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def info(self):
|
|
171
|
+
if self._info is None:
|
|
172
|
+
url = self
|
|
173
|
+
info = {}
|
|
174
|
+
if url.startswith('https://'):
|
|
175
|
+
parts = url.split('https://')[1].split('/', 3)
|
|
176
|
+
repo_endpoint = parts[2]
|
|
177
|
+
repo_name, repo_endpoint = self._fixup_endpoint(repo_endpoint)
|
|
178
|
+
info['host'] = parts[0]
|
|
179
|
+
info['group'] = parts[1]
|
|
180
|
+
info['repo_name'] = repo_name
|
|
181
|
+
info['repo_endpoint'] = repo_endpoint
|
|
182
|
+
info['user'] = None
|
|
183
|
+
info['protocol'] = 'https'
|
|
184
|
+
elif url.startswith('git@'):
|
|
185
|
+
parts = url.split('git@')[1].split(':')
|
|
186
|
+
repo_endpoint = parts[1].split('/')[1]
|
|
187
|
+
repo_name, repo_endpoint = self._fixup_endpoint(repo_endpoint)
|
|
188
|
+
info['host'] = parts[0]
|
|
189
|
+
info['group'] = parts[1].split('/')[0]
|
|
190
|
+
info['repo_name'] = repo_name
|
|
191
|
+
info['repo_endpoint'] = repo_endpoint
|
|
192
|
+
info['user'] = 'git'
|
|
193
|
+
info['protocol'] = 'git'
|
|
194
|
+
elif url.startswith('ssh://'):
|
|
195
|
+
parts = url.split('ssh://')[1].split('/', 3)
|
|
196
|
+
user = None
|
|
197
|
+
if '@' in parts[0]:
|
|
198
|
+
user, host = parts[0].split('@')
|
|
199
|
+
else:
|
|
200
|
+
host = parts[0]
|
|
201
|
+
repo_name, repo_endpoint = self._fixup_endpoint(parts[2])
|
|
202
|
+
info['host'] = host
|
|
203
|
+
info['user'] = user
|
|
204
|
+
info['group'] = parts[1]
|
|
205
|
+
info['repo_name'] = repo_name
|
|
206
|
+
info['repo_endpoint'] = repo_endpoint
|
|
207
|
+
info['protocol'] = 'ssh'
|
|
208
|
+
elif url.endswith('/.git'):
|
|
209
|
+
# An ssh protocol to an explicit directory
|
|
210
|
+
host, rest = url.split(':', 1)
|
|
211
|
+
parts = rest.rsplit('/', 2)
|
|
212
|
+
info['host'] = host
|
|
213
|
+
info['group'] = parts[0]
|
|
214
|
+
info['repo_name'] = parts[1]
|
|
215
|
+
info['repo_endpoint'] = parts[1] + '/.git'
|
|
216
|
+
info['protocol'] = 'scp'
|
|
217
|
+
elif '//' not in url and '@' not in url:
|
|
218
|
+
parts = url.split(':')
|
|
219
|
+
repo_name, repo_endpoint = self._fixup_endpoint(parts[1].split('/')[1])
|
|
220
|
+
info['host'] = parts[0]
|
|
221
|
+
info['group'] = parts[1].split('/')[0]
|
|
222
|
+
info['repo_name'] = repo_name
|
|
223
|
+
info['repo_endpoint'] = repo_endpoint
|
|
224
|
+
info['protocol'] = 'ssh'
|
|
225
|
+
else:
|
|
226
|
+
raise ValueError(url)
|
|
227
|
+
info['url'] = url
|
|
228
|
+
self._info = info
|
|
229
|
+
return self._info
|
|
230
|
+
|
|
231
|
+
def to_protocol(self, protocol):
|
|
232
|
+
"""
|
|
233
|
+
Convert the URL to a different protocol
|
|
234
|
+
"""
|
|
235
|
+
if protocol == 'git':
|
|
236
|
+
return self.to_git()
|
|
237
|
+
elif protocol in {'ssh', 'scp'}:
|
|
238
|
+
return self.to_ssh()
|
|
239
|
+
elif protocol == 'https':
|
|
240
|
+
return self.to_https()
|
|
241
|
+
else:
|
|
242
|
+
raise KeyError(protocol)
|
|
243
|
+
|
|
244
|
+
def to_git(self):
|
|
245
|
+
info = self.info
|
|
246
|
+
new_url = 'git@' + info['host'] + ':' + info['group'] + '/' + info['repo_endpoint']
|
|
247
|
+
return self.__class__(new_url)
|
|
248
|
+
|
|
249
|
+
def to_ssh(self):
|
|
250
|
+
info = self.info
|
|
251
|
+
user = info.get('user', None)
|
|
252
|
+
if user is None:
|
|
253
|
+
user_part = ''
|
|
254
|
+
else:
|
|
255
|
+
user_part = user + '@'
|
|
256
|
+
new_url = 'ssh://' + user_part + info['host'] + '/' + info['group'] + '/' + info['repo_endpoint']
|
|
257
|
+
return self.__class__(new_url)
|
|
258
|
+
|
|
259
|
+
def to_https(self):
|
|
260
|
+
info = self.info
|
|
261
|
+
new_url = 'https://' + info['host'] + '/' + info['group'] + '/' + info['repo_endpoint']
|
|
262
|
+
return self.__class__(new_url)
|
|
@@ -2,7 +2,30 @@
|
|
|
2
2
|
def make_dummy_git_repo():
|
|
3
3
|
import ubelt as ub
|
|
4
4
|
repo_dpath = ub.Path.appdir('git_well', 'tests', 'dummy-git-repo')
|
|
5
|
+
|
|
6
|
+
# On windows we need to use a tempdir because it doesn't seem to let you
|
|
7
|
+
# clean up after yourself.
|
|
8
|
+
if ub.WIN32:
|
|
9
|
+
import tempfile
|
|
10
|
+
repo_dpath = ub.Path(tempfile.mkdtemp()) / 'dummy-git-repo'
|
|
11
|
+
|
|
12
|
+
# try:
|
|
5
13
|
repo_dpath.delete().ensuredir()
|
|
14
|
+
# except PermissionError:
|
|
15
|
+
# if ub.WIN32:
|
|
16
|
+
# # On windows we might run into this on the CI server. The working
|
|
17
|
+
# # hypothesis for what could be causing it is that another git
|
|
18
|
+
# # instance might have a lock on data in the .git directory.
|
|
19
|
+
# # To work around this we are going to garbage collect to hopefully
|
|
20
|
+
# # cause any lock to be released, wait, and then try again.
|
|
21
|
+
# # another git instance might have a lock on a file.
|
|
22
|
+
# import gc
|
|
23
|
+
# import time
|
|
24
|
+
# gc.collect()
|
|
25
|
+
# time.sleep(1)
|
|
26
|
+
# repo_dpath.delete().ensuredir()
|
|
27
|
+
# else:
|
|
28
|
+
# raise
|
|
6
29
|
|
|
7
30
|
import git
|
|
8
31
|
repo = git.Repo.init(repo_dpath, initial_branch='main')
|
|
@@ -78,8 +78,12 @@ class GitAutoconfGpgsignCLI(scfg.DataConfig):
|
|
|
78
78
|
unique_fprs = {cand['fpr'] for cand in gpg_candidates}
|
|
79
79
|
|
|
80
80
|
if len(unique_fprs) == 0:
|
|
81
|
+
print('Error')
|
|
82
|
+
print(f'email_candidates = {ub.urepr(email_candidates, nl=1)}')
|
|
83
|
+
print(f'identify_file_cands = {ub.urepr(identify_file_cands, nl=1)}')
|
|
81
84
|
raise Exception('Unable to find any gpg candidates. '
|
|
82
|
-
'Is the repo not using git/ssh credentials?'
|
|
85
|
+
'Is the repo not using git/ssh credentials? '
|
|
86
|
+
'Try specifying --email=<youremail>.')
|
|
83
87
|
elif len(unique_fprs) != 1:
|
|
84
88
|
print(f'unique_fprs = {ub.urepr(unique_fprs, nl=1)}')
|
|
85
89
|
print('gpg_candidates = {}'.format(ub.urepr(gpg_candidates, nl=1)))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
import scriptconfig as scfg
|
|
3
3
|
import ubelt as ub
|
|
4
|
+
from git_well._utils import GitURL
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
# TODO: more protocols? ssh?
|
|
@@ -37,116 +38,6 @@ class GitRemoteProtocol(scfg.DataConfig):
|
|
|
37
38
|
'''))
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
class GitURL(str):
|
|
41
|
-
"""
|
|
42
|
-
Represents a url to a git repo and can parse info about / modify the
|
|
43
|
-
protocol
|
|
44
|
-
|
|
45
|
-
References:
|
|
46
|
-
https://git-scm.com/docs/git-clone#_git_urls
|
|
47
|
-
|
|
48
|
-
CommandLine:
|
|
49
|
-
xdoctest -m git_well.git_remote_protocol GitURL
|
|
50
|
-
|
|
51
|
-
Example:
|
|
52
|
-
>>> from git_well.git_remote_protocol import * # NOQA
|
|
53
|
-
>>> urls = [
|
|
54
|
-
>>> GitURL('https://foo.bar/user/repo.git'),
|
|
55
|
-
>>> GitURL('ssh://foo.bar/user/repo.git'),
|
|
56
|
-
>>> GitURL('ssh://git@foo.bar/user/repo.git'),
|
|
57
|
-
>>> GitURL('git@foo.bar:group/repo.git'),
|
|
58
|
-
>>> GitURL('host:path/to/my/repo/.git'),
|
|
59
|
-
>>> ]
|
|
60
|
-
>>> for url in urls:
|
|
61
|
-
>>> print('---')
|
|
62
|
-
>>> print(f'url = {url}')
|
|
63
|
-
>>> print(ub.urepr(url.info))
|
|
64
|
-
>>> print('As git : ' + url.to_git())
|
|
65
|
-
>>> print('As ssh : ' + url.to_ssh())
|
|
66
|
-
>>> print('As https : ' + url.to_https())
|
|
67
|
-
"""
|
|
68
|
-
|
|
69
|
-
def __init__(self, data):
|
|
70
|
-
# note: inheriting from str so data is handled in __new__
|
|
71
|
-
self._info = None
|
|
72
|
-
|
|
73
|
-
def _parse(self):
|
|
74
|
-
import parse
|
|
75
|
-
parse.Parser('ssh://{user}')
|
|
76
|
-
|
|
77
|
-
@property
|
|
78
|
-
def info(self):
|
|
79
|
-
if self._info is None:
|
|
80
|
-
url = self
|
|
81
|
-
info = {}
|
|
82
|
-
if url.startswith('https://'):
|
|
83
|
-
parts = url.split('https://')[1].split('/', 3)
|
|
84
|
-
info['host'] = parts[0]
|
|
85
|
-
info['group'] = parts[1]
|
|
86
|
-
info['repo_name'] = parts[2]
|
|
87
|
-
info['user'] = None
|
|
88
|
-
info['protocol'] = 'https'
|
|
89
|
-
elif url.startswith('git@'):
|
|
90
|
-
parts = url.split('git@')[1].split(':')
|
|
91
|
-
info['host'] = parts[0]
|
|
92
|
-
info['group'] = parts[1].split('/')[0]
|
|
93
|
-
info['repo_name'] = parts[1].split('/')[1]
|
|
94
|
-
info['user'] = 'git'
|
|
95
|
-
info['protocol'] = 'git'
|
|
96
|
-
elif url.startswith('ssh://'):
|
|
97
|
-
parts = url.split('ssh://')[1].split('/', 3)
|
|
98
|
-
user = None
|
|
99
|
-
if '@' in parts[0]:
|
|
100
|
-
user, host = parts[0].split('@')
|
|
101
|
-
else:
|
|
102
|
-
host = parts[0]
|
|
103
|
-
info['host'] = host
|
|
104
|
-
info['user'] = user
|
|
105
|
-
info['group'] = parts[1]
|
|
106
|
-
info['repo_name'] = parts[2]
|
|
107
|
-
info['protocol'] = 'ssh'
|
|
108
|
-
elif url.endswith('/.git'):
|
|
109
|
-
# An ssh protocol to an explicit directory
|
|
110
|
-
host, rest = url.split(':', 1)
|
|
111
|
-
parts = rest.rsplit('/', 2)
|
|
112
|
-
info['host'] = host
|
|
113
|
-
info['group'] = parts[0]
|
|
114
|
-
# info['group'] = ''
|
|
115
|
-
info['repo_name'] = parts[1] + '/.git'
|
|
116
|
-
info['protocol'] = 'scp'
|
|
117
|
-
elif '//' not in url and '@' not in url:
|
|
118
|
-
parts = url.split(':')
|
|
119
|
-
info['host'] = parts[0]
|
|
120
|
-
info['group'] = parts[1].split('/')[0]
|
|
121
|
-
info['repo_name'] = parts[1].split('/')[1]
|
|
122
|
-
info['protocol'] = 'ssh'
|
|
123
|
-
else:
|
|
124
|
-
raise ValueError(url)
|
|
125
|
-
info['url'] = url
|
|
126
|
-
self._info = info
|
|
127
|
-
return self._info
|
|
128
|
-
|
|
129
|
-
def to_git(self):
|
|
130
|
-
info = self.info
|
|
131
|
-
new_url = 'git@' + info['host'] + ':' + info['group'] + '/' + info['repo_name']
|
|
132
|
-
return self.__class__(new_url)
|
|
133
|
-
|
|
134
|
-
def to_ssh(self):
|
|
135
|
-
info = self.info
|
|
136
|
-
user = info.get('user', None)
|
|
137
|
-
if user is None:
|
|
138
|
-
user_part = ''
|
|
139
|
-
else:
|
|
140
|
-
user_part = user + '@'
|
|
141
|
-
new_url = 'ssh://' + user_part + info['host'] + '/' + info['group'] + '/' + info['repo_name']
|
|
142
|
-
return self.__class__(new_url)
|
|
143
|
-
|
|
144
|
-
def to_https(self):
|
|
145
|
-
info = self.info
|
|
146
|
-
new_url = 'https://' + info['host'] + '/' + info['group'] + '/' + info['repo_name']
|
|
147
|
-
return self.__class__(new_url)
|
|
148
|
-
|
|
149
|
-
|
|
150
41
|
def main(cmdline=1, **kwargs):
|
|
151
42
|
"""
|
|
152
43
|
Example:
|
|
@@ -644,7 +644,7 @@ def commits_between(repo, start, stop):
|
|
|
644
644
|
this gets messy any node on the path between <start> and <stop> has
|
|
645
645
|
more than one parent that is not on a path between <start> and <stop>
|
|
646
646
|
|
|
647
|
-
|
|
647
|
+
Note:
|
|
648
648
|
As a prefix: the carrot (^A) removes commits reachable from A.
|
|
649
649
|
As a suffix: the carrot (A^) references the 1st parent of A
|
|
650
650
|
Furthermore:
|
|
@@ -29,8 +29,13 @@ class GitSyncCLI(scfg.DataConfig):
|
|
|
29
29
|
|
|
30
30
|
def main(cmdline=True, **kwargs):
|
|
31
31
|
args = GitSyncCLI.cli(cmdline=cmdline, data=kwargs)
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
try:
|
|
33
|
+
import rich
|
|
34
|
+
from rich.markup import escape
|
|
35
|
+
rich.print('args = ' + escape(ub.urepr(args, nl=1)))
|
|
36
|
+
except Exception:
|
|
37
|
+
print('args = ' + ub.urepr(args, nl=1))
|
|
38
|
+
|
|
34
39
|
ns = dict(args).copy()
|
|
35
40
|
ns['host'] = ns['host'][0]
|
|
36
41
|
git_sync(**ns)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import scriptconfig as scfg
|
|
3
|
+
import ubelt as ub
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class GitUrlComponentsCLI(scfg.DataConfig):
|
|
7
|
+
"""
|
|
8
|
+
Access components of a git URL.
|
|
9
|
+
|
|
10
|
+
Usage
|
|
11
|
+
-----
|
|
12
|
+
python -m git_well url "https://foo.bar/user/repo.git"
|
|
13
|
+
python -m git_well url "https://foo.bar/user/repo.git" repo_name
|
|
14
|
+
|
|
15
|
+
SeeAlso
|
|
16
|
+
-------
|
|
17
|
+
:class:`GitURL`
|
|
18
|
+
"""
|
|
19
|
+
__command__ = 'url'
|
|
20
|
+
|
|
21
|
+
url = scfg.Value(None, help='the git url to parse', position=1)
|
|
22
|
+
component = scfg.Value(None, help='The component to access and print. If unspecified all info is printed in json format', position=2)
|
|
23
|
+
protocol = scfg.Value(None, help='If specified, convert to the specified protocol first')
|
|
24
|
+
verbose = scfg.Flag(False, help='verbosity level')
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def main(cls, argv=1, **kwargs):
|
|
28
|
+
"""
|
|
29
|
+
Example:
|
|
30
|
+
>>> # xdoctest: +SKIP
|
|
31
|
+
>>> from git_well.git_url_components import * # NOQA
|
|
32
|
+
>>> argv = 0
|
|
33
|
+
>>> kwargs = dict(url='https://foo.bar/user/repo.git')
|
|
34
|
+
>>> cls = GitUrlComponentsCLI
|
|
35
|
+
>>> config = cls(**kwargs)
|
|
36
|
+
>>> cls.main(argv=argv, **config)
|
|
37
|
+
>>> cls.main(argv=0, url='https://foo.bar/user/repo.git', component='repo_name')
|
|
38
|
+
>>> cls.main(argv=0, url='host:path/to/my/repo/.git')
|
|
39
|
+
"""
|
|
40
|
+
config = cls.cli(argv=argv, data=kwargs, strict=True)
|
|
41
|
+
if config.verbose:
|
|
42
|
+
import rich
|
|
43
|
+
from rich.markup import escape
|
|
44
|
+
rich.print('config = ' + escape(ub.urepr(config, nl=1)))
|
|
45
|
+
import json
|
|
46
|
+
if config['url'] is None:
|
|
47
|
+
raise ValueError('A url must be specified')
|
|
48
|
+
from git_well._utils import GitURL
|
|
49
|
+
url = GitURL(config['url'])
|
|
50
|
+
if config.protocol is not None:
|
|
51
|
+
url = url.to_protocol(config.protocol)
|
|
52
|
+
if config.component is None:
|
|
53
|
+
print(json.dumps(url.info, indent=' '))
|
|
54
|
+
else:
|
|
55
|
+
print(url.info[config.component])
|
|
56
|
+
|
|
57
|
+
__cli__ = GitUrlComponentsCLI
|
|
58
|
+
|
|
59
|
+
if __name__ == '__main__':
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
CommandLine:
|
|
63
|
+
python ~/code/git_well/git_well/git_url_components.py
|
|
64
|
+
python -m git_well.git_url_components
|
|
65
|
+
"""
|
|
66
|
+
__cli__.main()
|
|
@@ -16,6 +16,7 @@ class GitWellModalCLI(scfg.ModalCLI):
|
|
|
16
16
|
from git_well.git_remote_protocol import __cli__ as remote_protocol
|
|
17
17
|
from git_well.git_discover_remote import __cli__ as discover_remote
|
|
18
18
|
from git_well.git_autoconf_gpgsign import __cli__ as autoconf_gpgsign
|
|
19
|
+
from git_well.git_url_components import __cli__ as url
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
def main():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: git_well
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: The git_well module
|
|
5
5
|
Home-page: https://github.com/Erotemic/git_well
|
|
6
6
|
Author: Jon Crall
|
|
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
21
|
Requires-Python: >=3.7
|
|
21
22
|
Description-Content-Type: text/x-rst
|
|
22
23
|
Requires-Dist: ubelt>=1.3.3
|
|
@@ -187,6 +188,17 @@ Requires-Dist: sphinx-autoapi==1.8.4; extra == "docs-strict"
|
|
|
187
188
|
Requires-Dist: Pygments==2.9.0; extra == "docs-strict"
|
|
188
189
|
Requires-Dist: myst_parser==0.18.0; extra == "docs-strict"
|
|
189
190
|
Requires-Dist: sphinx-reredirects==0.0.1; extra == "docs-strict"
|
|
191
|
+
Dynamic: author
|
|
192
|
+
Dynamic: author-email
|
|
193
|
+
Dynamic: classifier
|
|
194
|
+
Dynamic: description
|
|
195
|
+
Dynamic: description-content-type
|
|
196
|
+
Dynamic: home-page
|
|
197
|
+
Dynamic: license
|
|
198
|
+
Dynamic: provides-extra
|
|
199
|
+
Dynamic: requires-dist
|
|
200
|
+
Dynamic: requires-python
|
|
201
|
+
Dynamic: summary
|
|
190
202
|
|
|
191
203
|
The git_well Module
|
|
192
204
|
===================
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
MANIFEST.in
|
|
1
2
|
README.rst
|
|
2
3
|
pyproject.toml
|
|
3
4
|
setup.py
|
|
@@ -26,6 +27,7 @@ git_well/git_sync.py
|
|
|
26
27
|
git_well/git_sync.pyi
|
|
27
28
|
git_well/git_track_upstream.py
|
|
28
29
|
git_well/git_track_upstream.pyi
|
|
30
|
+
git_well/git_url_components.py
|
|
29
31
|
git_well/main.py
|
|
30
32
|
git_well/main.pyi
|
|
31
33
|
git_well/py.typed
|
|
@@ -38,5 +40,9 @@ git_well.egg-info/entry_points.txt
|
|
|
38
40
|
git_well.egg-info/requires.txt
|
|
39
41
|
git_well.egg-info/top_level.txt
|
|
40
42
|
git_well/demo/__init__.py
|
|
43
|
+
requirements/docs.txt
|
|
44
|
+
requirements/optional.txt
|
|
45
|
+
requirements/runtime.txt
|
|
46
|
+
requirements/tests.txt
|
|
41
47
|
tests/test_cli.py
|
|
42
48
|
tests/test_import.py
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Add requirements here
|
|
2
|
+
|
|
3
|
+
ubelt >= 1.3.3
|
|
4
|
+
scriptconfig>=0.7.10 ; python_version >= '3.6' # Python 3.6+
|
|
5
|
+
rich>=12.4.4 ; python_version >= '3.8' # Python 3.8+
|
|
6
|
+
rich>=11.2.0 ; python_version < '3.8' and python_version >= '3.6' # Python 3.6
|
|
7
|
+
git-python>=1.0.0 ; python_version >= '2.7' # Python 2.7+
|
|
8
|
+
packaging>=21.3
|
|
9
|
+
|
|
10
|
+
networkx>=2.8 ; python_version < '4.0' and python_version >= '3.11' # Python 3.11+
|
|
11
|
+
networkx>=2.7 ; python_version < '3.11' and python_version >= '3.8' # Python 3.8-3.11
|
|
12
|
+
networkx>=2.6.2 ; python_version < '3.8' and python_version >= '3.7' # Python 3.7
|
|
13
|
+
networkx>=2.2.0,<=2.5.1 ; python_version < '3.7.0' and python_version >= '3.6.0' # Python 3.6
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
xdoctest>=1.1.3
|
|
2
|
+
|
|
3
|
+
# Pin maximum pytest versions for older python versions
|
|
4
|
+
# TODO: determine what the actual minimum and maximum acceptable versions of
|
|
5
|
+
# pytest (that are also compatible with xdoctest) are for each legacy python
|
|
6
|
+
# major.minor version.
|
|
7
|
+
# See ~/local/tools/supported_python_versions_pip.py for helper script
|
|
8
|
+
pytest>=6.2.5 ; python_version >= '3.10.0' # Python 3.10+
|
|
9
|
+
pytest>=4.6.0 ; python_version < '3.10.0' and python_version >= '3.7.0' # Python 3.7-3.9
|
|
10
|
+
pytest>=4.6.0 ; python_version < '3.7.0' and python_version >= '3.6.0' # Python 3.6
|
|
11
|
+
pytest>=4.6.0, <= 6.1.2 ; python_version < '3.6.0' and python_version >= '3.5.0' # Python 3.5
|
|
12
|
+
pytest>=4.6.0, <= 4.6.11 ; python_version < '3.5.0' and python_version >= '3.4.0' # Python 3.4
|
|
13
|
+
pytest>=4.6.0, <= 4.6.11 ; python_version < '2.8.0' and python_version >= '2.7.0' # Python 2.7
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
#pytest-cov >= 2.6.0 ; python_version >= '3.7.0'
|
|
17
|
+
#pytest-cov >= 2.6.0, <= 2.8.1 ; python_version < '3.7.0' and python_version >= '3.6.0'
|
|
18
|
+
|
|
19
|
+
pytest-cov>=3.0.0 ; python_version >= '3.6.0' # Python 3.6+
|
|
20
|
+
pytest-cov>=2.9.0 ; python_version < '3.6.0' and python_version >= '3.5.0' # Python 3.5
|
|
21
|
+
pytest-cov>=2.8.1 ; python_version < '3.5.0' and python_version >= '3.4.0' # Python 3.4
|
|
22
|
+
pytest-cov>=2.8.1 ; python_version < '2.8.0' and python_version >= '2.7.0' # Python 2.7
|
|
23
|
+
|
|
24
|
+
# python ~/local/tools/supported_python_versions_pip.py pytest-timeout
|
|
25
|
+
pytest-timeout>=1.4.2
|
|
26
|
+
|
|
27
|
+
# python ~/local/tools/supported_python_versions_pip.py xdoctest
|
|
28
|
+
# python ~/local/tools/supported_python_versions_pip.py coverage
|
|
29
|
+
coverage>=6.1.1 ; python_version >= '3.10' # Python 3.10+
|
|
30
|
+
coverage>=5.3.1 ; python_version < '3.10' and python_version >= '3.9' # Python 3.9
|
|
31
|
+
coverage>=6.1.1 ; python_version < '3.9' and python_version >= '3.8' # Python 3.8
|
|
32
|
+
coverage>=6.1.1 ; python_version < '3.8' and python_version >= '3.7' # Python 3.7
|
|
33
|
+
coverage>=6.1.1 ; python_version < '3.7' and python_version >= '3.6' # Python 3.6
|
|
34
|
+
coverage>=5.3.1 ; python_version < '3.6' and python_version >= '3.5' # Python 3.5
|
|
35
|
+
coverage>=4.3.4 ; python_version < '3.5' and python_version >= '3.4' # Python 3.4
|
|
36
|
+
coverage>=5.3.1 ; python_version < '3.4' and python_version >= '2.7' # Python 2.7
|
|
37
|
+
coverage>=4.5 ; python_version < '2.7' and python_version >= '2.6' # Python 2.6
|
|
@@ -70,7 +70,7 @@ def parse_requirements(fname="requirements.txt", versions=False):
|
|
|
70
70
|
|
|
71
71
|
Args:
|
|
72
72
|
fname (str): path to requirements file
|
|
73
|
-
versions (bool | str
|
|
73
|
+
versions (bool | str):
|
|
74
74
|
If true include version specs.
|
|
75
75
|
If strict, then pin to the minimum version.
|
|
76
76
|
|
|
@@ -106,7 +106,7 @@ def parse_requirements(fname="requirements.txt", versions=False):
|
|
|
106
106
|
info["package"] = line.split("#egg=")[1]
|
|
107
107
|
else:
|
|
108
108
|
if "--find-links" in line:
|
|
109
|
-
# setuptools
|
|
109
|
+
# setuptools does not seem to handle find links
|
|
110
110
|
line = line.split("--find-links")[0]
|
|
111
111
|
if ";" in line:
|
|
112
112
|
pkgpart, platpart = line.split(";")
|
|
@@ -159,7 +159,8 @@ def parse_requirements(fname="requirements.txt", versions=False):
|
|
|
159
159
|
if plat_deps is not None:
|
|
160
160
|
parts.append(";" + plat_deps)
|
|
161
161
|
item = "".join(parts)
|
|
162
|
-
|
|
162
|
+
if item:
|
|
163
|
+
yield item
|
|
163
164
|
|
|
164
165
|
packages = list(gen_packages_items())
|
|
165
166
|
return packages
|
|
@@ -198,7 +199,6 @@ def parse_requirements(fname="requirements.txt", versions=False):
|
|
|
198
199
|
NAME = "git_well"
|
|
199
200
|
INIT_PATH = "git_well/__init__.py"
|
|
200
201
|
VERSION = parse_version(INIT_PATH)
|
|
201
|
-
|
|
202
202
|
if __name__ == "__main__":
|
|
203
203
|
setupkw = {}
|
|
204
204
|
|
|
@@ -244,6 +244,7 @@ if __name__ == "__main__":
|
|
|
244
244
|
"Programming Language :: Python :: 3.10",
|
|
245
245
|
"Programming Language :: Python :: 3.11",
|
|
246
246
|
"Programming Language :: Python :: 3.12",
|
|
247
|
+
"Programming Language :: Python :: 3.13",
|
|
247
248
|
]
|
|
248
249
|
setupkw["entry_points"] = {
|
|
249
250
|
"console_scripts": [
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import ubelt as ub
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def rich_print(*args, **kwargs):
|
|
5
|
-
try:
|
|
6
|
-
from rich import print as print_
|
|
7
|
-
except Exception:
|
|
8
|
-
print_ = print
|
|
9
|
-
return print_(*args, **kwargs)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def find_merged_branches(repo, main_branch='main'):
|
|
13
|
-
# git branch --merged main
|
|
14
|
-
# main_branch = 'main'
|
|
15
|
-
merged_branches = [p.replace('*', '').strip() for p in repo.git.branch(merged=main_branch).split('\n') if p.strip()]
|
|
16
|
-
merged_branches = ub.oset(merged_branches) - {main_branch}
|
|
17
|
-
return merged_branches
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def confirm(msg):
|
|
21
|
-
try:
|
|
22
|
-
from rich import prompt
|
|
23
|
-
ret = prompt.Confirm.ask(msg)
|
|
24
|
-
except ImportError:
|
|
25
|
-
while True:
|
|
26
|
-
ans = input(msg + ' [y/n]')
|
|
27
|
-
if ans in {'y', 'yes'}:
|
|
28
|
-
ret = True
|
|
29
|
-
break
|
|
30
|
-
elif ans in {'n', 'no'}:
|
|
31
|
-
ret = False
|
|
32
|
-
break
|
|
33
|
-
else:
|
|
34
|
-
print('invalid response')
|
|
35
|
-
return ret
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def choice_prompt(msg, choices):
|
|
39
|
-
"""
|
|
40
|
-
Ignore:
|
|
41
|
-
choice_prompt('which one?', choices=['a', 'b', 'c'])
|
|
42
|
-
"""
|
|
43
|
-
try:
|
|
44
|
-
from rich.prompt import Prompt, InvalidResponse
|
|
45
|
-
except ImportError:
|
|
46
|
-
print('Rich is required here')
|
|
47
|
-
raise
|
|
48
|
-
|
|
49
|
-
class ChoiceWithIntPrompt(Prompt):
|
|
50
|
-
"""
|
|
51
|
-
Assigns an integer to each choice.
|
|
52
|
-
"""
|
|
53
|
-
def make_prompt(self, default):
|
|
54
|
-
prompt = self.prompt.copy()
|
|
55
|
-
prompt.end = ""
|
|
56
|
-
|
|
57
|
-
if self.show_choices and self.choices:
|
|
58
|
-
prompt.append('\n')
|
|
59
|
-
for idx, choice in enumerate(self.choices, start=1):
|
|
60
|
-
try:
|
|
61
|
-
int(choice)
|
|
62
|
-
except ValueError:
|
|
63
|
-
...
|
|
64
|
-
else:
|
|
65
|
-
raise AssertionError('choices cannot be integers')
|
|
66
|
-
|
|
67
|
-
prompt.append(f'{idx}. ', style='json.number')
|
|
68
|
-
prompt.append(f'{choice}\n', style="prompt")
|
|
69
|
-
if (
|
|
70
|
-
default != ...
|
|
71
|
-
and self.show_default
|
|
72
|
-
and isinstance(default, (str, self.response_type))
|
|
73
|
-
):
|
|
74
|
-
prompt.append(" ")
|
|
75
|
-
_default = self.render_default(default)
|
|
76
|
-
prompt.append(_default)
|
|
77
|
-
|
|
78
|
-
prompt.append(self.prompt_suffix)
|
|
79
|
-
return prompt
|
|
80
|
-
|
|
81
|
-
def process_response(self, value: str):
|
|
82
|
-
value = value.strip()
|
|
83
|
-
assert self.choices is not None
|
|
84
|
-
try:
|
|
85
|
-
return_value = self.response_type(value)
|
|
86
|
-
except ValueError:
|
|
87
|
-
raise InvalidResponse(self.validate_error_message)
|
|
88
|
-
|
|
89
|
-
try:
|
|
90
|
-
idx = int(return_value) - 1
|
|
91
|
-
return_value = self.choices[idx]
|
|
92
|
-
except Exception:
|
|
93
|
-
...
|
|
94
|
-
|
|
95
|
-
if return_value not in self.choices:
|
|
96
|
-
raise InvalidResponse(self.illegal_choice_message)
|
|
97
|
-
|
|
98
|
-
return return_value
|
|
99
|
-
|
|
100
|
-
return ChoiceWithIntPrompt.ask(msg, choices=choices)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def find_git_root(dpath):
|
|
104
|
-
cwd = ub.Path(dpath).absolute()
|
|
105
|
-
parts = cwd.parts
|
|
106
|
-
found = None
|
|
107
|
-
for i in reversed(range(0, len(parts) + 1)):
|
|
108
|
-
p = ub.Path(*parts[0:i])
|
|
109
|
-
cand = p / '.git'
|
|
110
|
-
if cand.exists():
|
|
111
|
-
found = p
|
|
112
|
-
break
|
|
113
|
-
if found is None:
|
|
114
|
-
raise Exception('cannot find git root')
|
|
115
|
-
return found
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|