aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremmett1 <me@emmett1.my>2026-06-22 13:36:51 +0800
committeremmett1 <me@emmett1.my>2026-06-22 13:36:51 +0800
commitee828908134f324f19ee229c24a27c6cb8e55499 (patch)
tree88f12cb060de4b11921703778c1036f564df5dbc
parenteb0fe6462d03c6c9e570955fa27035338875b9fb (diff)
downloadautils-ee828908134f324f19ee229c24a27c6cb8e55499.tar.gz
autils-ee828908134f324f19ee229c24a27c6cb8e55499.zip
reposync updated0.5
-rwxr-xr-xreposync24
1 files changed, 19 insertions, 5 deletions
diff --git a/reposync b/reposync
index 268e92b..9354480 100755
--- a/reposync
+++ b/reposync
@@ -40,13 +40,27 @@ syncrepo() {
if [ ! -d "$path/.git" ]; then
log "=> Cloning repo into $path..."
- run_cmd "mkdir -p \"$path\""
- run_cmd "git clone --branch \"$branch\" --single-branch \"$url\" \"$path\""
+ if [ "$DRY_RUN" ]; then
+ log " [dry-run] mkdir -p \"$path\" && git clone --quiet --branch \"$branch\" --single-branch \"$url\" \"$path\""
+ else
+ mkdir -p "$path"
+ git clone --quiet --branch "$branch" --single-branch "$url" "$path"
+ fi
else
log "=> Updating repo $path..."
- run_cmd "cd \"$path\" && git fetch origin \"$branch\""
- run_cmd "cd \"$path\" && git reset --hard \"origin/$branch\""
- run_cmd "cd \"$path\" && git clean -fdx"
+ old_head=$(cd "$path" && git rev-parse HEAD 2>/dev/null) || true
+ if [ "$DRY_RUN" ]; then
+ log " [dry-run] git fetch --quiet origin $branch && git reset --quiet --hard origin/$branch && git clean -q -fdx"
+ else
+ cd "$path" && git fetch --quiet origin "$branch"
+ cd "$path" && git reset --quiet --hard "origin/$branch"
+ cd "$path" && git clean -q -fdx
+ fi
+ new_head=$(cd "$path" && git rev-parse HEAD 2>/dev/null) || true
+ if [ "$old_head" ] && [ "$new_head" ] && [ "$old_head" != "$new_head" ]; then
+ log "=> Changed files:"
+ cd "$path" && git --no-pager diff --stat "$old_head" "$new_head" 2>/dev/null || true
+ fi
fi
}