Skip to content

Commit

Permalink
Add check for remotes being as expected
Browse files Browse the repository at this point in the history
Since we moved GenConfig and some of its associated repositories,
get_dependencies.sh should detect and tell the user that they will need
to allow it to re-clone them if their remotes are out-of-date.
Otherwise pulls can/will fail.

Signed-off-by: Samuel E. Browne <[email protected]>
  • Loading branch information
sebrowne committed Jan 13, 2025
1 parent bc6496e commit b71d29e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/framework/get_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,23 @@ function tril_genconfig_clone_or_update_repo() {
echo

if [[ -d ${sub_dir} ]] ; then
echo "STATUS: ${sub_dir}: Fetching remote repo"
cd ${sub_dir}
tril_genconfig_assert_pwd_is_git_repo
cmd="git fetch"
retry_command "${cmd}"
remote=$(git remote get-url origin)
if [[ ${git_url} == *"${remote}"* ]]

This comment has been minimized.

Copy link
@bartlettroscoe

bartlettroscoe Jan 13, 2025

Member

@sebrowne, the one thing that would trip me up and other developers is that I use git@<site-base>:<org>/<repo>.git instead of https:<site-base>/<org>/<repo>.git. The way to fix this would be extract and normalize the part <site-base>:<org>/<repo> and match on that. May not be all that hard to do that normalization.

This comment has been minimized.

Copy link
@sebrowne

sebrowne Jan 14, 2025

Author Contributor

It shouldn't, because get_dependencies.sh did the cloning in the first place, no? I don't think we need to support the "I cloned it manually and want get_dependencies.sh to do the update" use case.

This comment has been minimized.

Copy link
@bartlettroscoe

bartlettroscoe Jan 14, 2025

Member

Not a big deal either way. But I created a little Python tool to normalize Git URLs for a comparison like this and created a new PR:

Should make things nicer for people who modify the GenConfig repos but still need to run this script.

then
echo "STATUS: ${sub_dir}: Fetching remote repo"
tril_genconfig_assert_pwd_is_git_repo
cmd="git fetch"
retry_command "${cmd}"
else
echo "ERROR: Current remote origin does not match expected!" >&2
echo "Please remove/move '$(pwd)' and re-run this script" >&2
echo "" >&2
echo "Current: ${remote}" >&2
echo "Expected: ${git_url}" >&2
echo "" >&2
exit 1
fi
else
echo "STATUS: ${sub_dir}: Cloning from '${git_url}'"
cmd="git clone ${git_url} ${sub_dir}"
Expand Down

0 comments on commit b71d29e

Please sign in to comment.