git source element uses inconsistent remote names and cannot update local repo
Summary
In some configurations, the git source element uses different remote names when cloning a repository and when trying to update the local repository later. I was able to reproduce this only when there is a mirror configured on the same HTTP host as the canonical URL.
Steps to reproduce
-
Start an HTTP server serving static files from some directory you can write to.
-
Define shell variables
$http_dir
as the directory served over HTTP, and$http_url
as its HTTP URL. -
In a temporary directory, run the following commands.
cat >project.conf <<EOT
name: build
element-path: .
aliases:
local: $http_url
mirrors:
- name: my_mirror
aliases:
local:
- $http_url/fake-mirror/
EOT
git init $http_dir/upstream
(cd $http_dir/upstream && echo foo > foo && git add foo && git commit -m foo)
GIT_DIR=$http_dir/upstream/.git git update-server-info
upstream_ref=$(GIT_DIR=$http_dir/upstream/.git git rev-parse HEAD)
cat >upstream.bst <<EOT
kind: import
sources:
- kind: git
url: local:upstream/.git
ref: $upstream_ref
config:
target: /
EOT
bst build upstream.bst
(cd $http_dir/upstream && echo bar > foo && git add foo && git commit -m bar)
GIT_DIR=$http_dir/upstream/.git git update-server-info
new_upstream_ref=$(GIT_DIR=$http_dir/upstream/.git git rev-parse HEAD)
sed -i "s/$upstream_ref/$new_upstream_ref/" upstream.bst
bst build upstream.bst
What is the current bug behavior?
The second build fails, with error messages like:
Running host command /home/bwh/.cache/buildstream/sources/git/local_upstream__git: /usr/bin/git fetch http___192_168_122_1__bwh_bst_test_ --prune --force --tags
[--:--:--] STATUS upstream.bst-0: Running host command
/usr/bin/git fetch http___192_168_122_1__bwh_bst_test_ --prune --force --tags
fatal: 'http___192_168_122_1__bwh_bst_test_' does not appear to be a git repository
fatal: Could not read from remote repository.
The repository in /home/bwh/.cache/buildstream/sources/git/local_upstream__git
only has the remotes:
http___192_168_122_1__bwh_bst_test__fake_mirror_
origin
What is the expected correct behavior?
Either the first build should have created the local repo with a remote named after the canonical URL, or the second build should fetch from the origin
remote.
Relevant logs and/or screenshots
Possible fixes
Other relevant information
- BuildStream version affected: /milestone %BuildStream_v1.4
I'm running BuildStream 1.4.3 and have not tested the master branch.