Submitted by Admin on

Interesting task to get all changed files from the PR.

It's useful when you don't want to mess with cherry-picks or copy files manually.

The script will download PR diff info via cURL and parse the filenames of changed files.

readarray -t changed_files < <(curl -L $URL.diff \
  | grep "diff --git" \
  | sort \
  | cut -d" " -f3 \
  | cut -c3-)

Next part is the simple copy with rsync to the folder you've provided.

for item in "${changed_files[@]}"; do
    echo "Processing: $item"
    rsync -avq --mkpath "$item" "$DIR_TO_COPY/$item"
done

Link to the source code

Теги