Skip to content

Commit 23878f6

Browse files
committed
fix: 🐛 improve repository name extraction and refactor commit selection logic
1 parent bf15932 commit 23878f6

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

src/gitutils/_git-degit.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ eval $(
1717
# Get the repository host
1818
host=$(echo "${repo}" | sed -E 's/https?:\/\/([^/]+)\/.*/\1/')
1919

20-
# Keep only the repository name
21-
repo=$(echo "${repo}" | sed -E 's/.*github.com\/([^/]+)\/([^/]+).*/\1\/\2/')
20+
# Keep only the repository name. Eventually remove .git suffix
21+
repo=$(echo "${repo}" | sed -E -e 's/.*github.com\/([^/]+)\/([^/]+).*/\1\/\2/' -e 's/\.git$//')
2222

2323
# Check if the directory is provided
2424
if [ -z "${directory}" ]; then

src/gitutils/_git-getcommit.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ cd "$(git rev-parse --show-toplevel)"
1414
# Fetch updates from the remote repository
1515
git fetch --progress --prune --recurse-submodules=no origin >/dev/null
1616

17-
if [ -n "$force" ]; then
18-
zz_log w "Force mode enabled, overwriting pushed history"
19-
git forceable >&2
20-
read -p 'Which commit? ' sha
21-
elif [ -z "$sha" ]; then
22-
git fixable >&2
23-
read -p 'Which commit? ' sha
24-
else
25-
#### Use given commit
26-
sha=$1
17+
if [ -z "$sha" ]; then
18+
if [ -n "$force" ]; then
19+
zz_log w "Force mode enabled, overwriting pushed history"
20+
git forceable >&2
21+
read -p 'Which commit? ' sha
22+
else
23+
git fixable >&2
24+
read -p 'Which commit? ' sha
25+
fi
2726
fi
2827

2928
#### Display commit to fixup, keep only the sha, remove new line

0 commit comments

Comments
 (0)