Files
Fast-Export/t/set_origin.t
Günther Nußmüller ad96531587 Fix TypeError when using the --origin option
Encode the `name` parameter to bytes (using the utf8 codec).

This fixes the `TypeError` in subsequent concatenations in `get_branch`:

```
Traceback (most recent call last):
  # stack omitted for brevity
  File "C:\Dev\git-migration\fast-export\hg2git.py", line 73, in get_branch
    return origin_name + b'/' + name
TypeError: can only concatenate str (not "bytes") to str
```

The conversion is done unconditionally since the passed
parameter is currently always of type `str`.
2025-07-16 14:41:45 +02:00

60 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2023 Felipe Contreras
# Copyright (c) 2025 Günther Nußmüller
#
test_description='Set origin tests'
. "${SHARNESS_TEST_SRCDIR-$(dirname "$0")/sharness}"/sharness.sh || exit 1
check() {
git -C "$1" fast-export --all > actual
test_cmp "$SHARNESS_TEST_DIRECTORY"/set_origin.expected actual
}
git_clone() {
(
git init -q "$2" &&
cd "$2" &&
git config core.ignoreCase false &&
hg-fast-export.sh --repo "../$1" --origin "$3"
)
}
setup() {
cat > "$HOME"/.hgrc <<-EOF
[ui]
username = H G Wells <wells@example.com>
EOF
}
make-branch() {
hg branch "$1"
FILE=$(echo "$1" | sha1sum | cut -d " " -f 1)
echo "$1" > $FILE
hg add $FILE
hg commit -d "2023-03-17 $2:00Z" -m "Added file in branch $1"
}
setup
test_expect_success 'basic' '
test_when_finished "rm -rf hgrepo gitrepo" &&
(
hg init hgrepo &&
cd hgrepo &&
echo zero > content &&
hg add content &&
hg commit -m zero -d "2023-03-17 01:00Z" &&
make-branch branch1 02 &&
make-branch branch2 03
) &&
git_clone hgrepo gitrepo prefix &&
check gitrepo
'
test_done