Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Shawn Webb
Git Lab
Commits
b66567e0
Unverified
Commit
b66567e0
authored
Apr 07, 2021
by
Jonah Brüchert
Browse files
Add rewrite-remote subcommand
parent
a3b0acb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
lab/__init__.py
View file @
b66567e0
...
...
@@ -26,6 +26,7 @@ from lab import (
issues
,
snippet
,
workflow
,
rewrite_remote
)
from
lab.utils
import
Utils
,
LogType
...
...
@@ -52,6 +53,7 @@ class Parser: # pylint: disable=R0903
issues
,
snippet
,
workflow
,
rewrite_remote
]
for
command
in
command_list
:
parser
=
command
.
parser
(
self
.
subparsers
)
...
...
lab/rewrite_remote.py
0 → 100644
View file @
b66567e0
"""
Module of the rewrite-remote subcommand
"""
# SPDX-FileCopyrightText: 2020 Jonah Brüchert <jbb@kaidan.im>
#
# SPDX-License-Identifier: GPL-2.0-or-later
import
argparse
from
git
import
Repo
from
lab.utils
import
Utils
def
parser
(
subparsers
:
argparse
.
_SubParsersAction
,
# pylint: disable=protected-access
)
->
argparse
.
ArgumentParser
:
rewrite_remote_parser
:
argparse
.
ArgumentParser
=
subparsers
.
add_parser
(
"rewrite-remote"
,
help
=
"Rewrite the remote url to ssh"
)
rewrite_remote_parser
.
add_argument
(
"remote"
,
type
=
str
,
nargs
=
1
,
help
=
"Name of the remote to rewrite"
,
)
return
rewrite_remote_parser
def
run
(
args
:
argparse
.
Namespace
)
->
None
:
repo
:
Repo
=
Utils
.
get_cwd_repo
()
remote_url
=
repo
.
git
.
remote
(
"get-url"
,
args
.
remote
)
ssh_url
=
Utils
.
ssh_url_from_http
(
Utils
.
normalize_url
(
remote_url
))
repo
.
git
.
remote
(
"set-url"
,
args
.
remote
,
ssh_url
)
lab/utils.py
View file @
b66567e0
...
...
@@ -47,6 +47,7 @@ class TextFormatting: # pylint: disable=too-few-public-methods
underline
:
Final
[
str
]
=
"
\033
[4m"
end
:
Final
[
str
]
=
"
\033
[0m"
class
Utils
:
"""
This class contains static methods for common tasks
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment