Skip to content

Commit 66fe101

Browse files
committed
align better with github url format
1 parent 744a062 commit 66fe101

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

git_pr_helper/actions/action_add.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,27 @@ def run(console: rich.console.Console, args: argparse.Namespace):
108108

109109
else:
110110
console.show_cursor()
111-
info = console.input(
112-
rich.text.Text.assemble(
113-
"Enter branch info (",
114-
("<user>/<repo>", styles.ACCENT),
115-
":",
116-
("<branch>", styles.ACCENT),
117-
"): ",
111+
while True:
112+
info = console.input(
113+
rich.text.Text.assemble(
114+
"Enter branch info (",
115+
("<user>/<repo>", styles.ACCENT),
116+
"/tree/",
117+
("<branch>", styles.ACCENT),
118+
"): ",
119+
)
120+
)
121+
remote, found, branch = info.partition("/tree/")
122+
if found:
123+
break
124+
console.print(
125+
rich.text.Text.assemble(
126+
("error", styles.ERROR),
127+
": invalid format: ",
128+
rich.text.Text(info, styles.ERROR),
129+
)
118130
)
119-
)
120131
console.show_cursor(False)
121-
remote, _, branch = info.partition(":")
122132
if "/" in remote:
123133
remote = f"git@github.com:{remote}.git"
124134

git_pr_helper/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99

1010
def abbreviate_remote(remote: str):
11-
return remove_around(remote, "git@github.com:", ".git")
11+
return (
12+
remote.removeprefix("git@github.com:")
13+
.removeprefix("https://github.com/")
14+
.removesuffix(".git")
15+
)
1216

1317

1418
def remove_around(data: str, before: str, after: str):

0 commit comments

Comments
 (0)