LoginSignup
0
0

repo init で変数でurlを渡すようにしたらエラーになる

Last updated at Posted at 2023-07-13

この記事について

repo init がエラーになる要因の1つと、その回避方法を紹介します。

やりたかったこと

repo init に渡すurl, branch, xmlファイルを変数にして、汎用的にしたかったため、REPO_URL, REPO_BRANCH, REPO_XML を環境変数で設定して、repo initコマンドに渡すスクリプトを作成した。

repo_url=$REPO_URL
repo_branch=$REPO_BRANCH
repo_xml=$REPO_XML

cd $HOME

echo "RUN repo init from ${repo_url}"
repo init --depth=1 -u ${repo_url} -b "${repo_branch}" -m "${repo_xml}" --repo-branch=repo-1

たが実行すると、以下のようなエラーが発生して、repo initが失敗した。

Get ${repo_url}/clone.bundle
fatal: cloning the git-repo repository failed, will remove '.repo/repo' 

原因と対策

実は$REPO_URL という変数はrepoコマンドの予約変数となっていて、https://gerrit.googlesource.com/git-repo というurlが入っている。repoコマンドではこのサイトからrepoのテンプレート等をcloneする必要があるが、$REPO_URLを書き換えてしまったため、エラー終了していた。

REPO_URLを別名に変更することで回避できる。

repo_url=$REPO_MANIFEST_URL
repo_branch=$REPO_BRANCH
repo_xml=$REPO_XML

cd $HOME

echo "RUN repo init from ${repo_url}"
repo init --depth=1 -u ${repo_url} -b "${repo_branch}" -m "${repo_xml}" --repo-branch=repo-1

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0