diff --git a/third_party/init.bash b/third_party/init.bash index e45e394..f7066ba 100644 --- a/third_party/init.bash +++ b/third_party/init.bash @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -euo pipefail - root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$root" +origin="$(git remote get-url origin)" +origin="${origin%/}" +remote_root="$(printf '%s\n' "$origin" | sed -E 's#/[^/]+(\.git)?$##')" fetch_repo() { local repo="$1" local branch="$2" @@ -17,12 +19,11 @@ fetch_repo() { git clone --branch "$branch" --single-branch "$repo" "$dir" fi } - fetch_repo_ex() { local name="$1" - repo="http://192.168.1.75:3000/psc/${name}" - branch="master" - fetch_repo "${repo}" "$branch" "third_party/${name}" + local repo="${remote_root}/${name}" + local branch="master" + fetch_repo "$repo" "$branch" "third_party/${name}" } fetch_repo_ex "build_infra" diff --git a/third_party/init.ps1 b/third_party/init.ps1 index 59f23f7..00b70e6 100644 --- a/third_party/init.ps1 +++ b/third_party/init.ps1 @@ -6,6 +6,9 @@ if ( [string]::IsNullOrWhiteSpace($scriptDir)) } $root = (Resolve-Path -LiteralPath (Join-Path $scriptDir "..")).Path Set-Location -LiteralPath $root +$origin = git remote get-url origin +$origin = $origin.TrimEnd("/") +$remoteRoot = $origin -replace "/[^/]+(\.git)?$", "" function Fetch-Repo { param( @@ -31,10 +34,12 @@ function Fetch-RepoEx param( [string]$Name ) - $repo = "http://192.168.1.75:3000/psc/$Name" + $repo = "$remoteRoot/$Name" $branch = "master" Fetch-Repo -Repo $repo -Branch $branch -Dir "third_party/$Name" } + + Fetch-RepoEx "build_infra" Fetch-RepoEx "CPP_Core" Fetch-RepoEx "Graphic_Core" \ No newline at end of file