From fe87ae1b79e8a3aa3cf604ec244666ea62738d86 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 4 Aug 2018 14:05:54 +0200 Subject: [PATCH] Fix `sync_templates_and_ci`. --- developer/bin/sync_templates_and_ci | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/developer/bin/sync_templates_and_ci b/developer/bin/sync_templates_and_ci index e3d5b0417e..1497d9334f 100755 --- a/developer/bin/sync_templates_and_ci +++ b/developer/bin/sync_templates_and_ci @@ -1,5 +1,8 @@ #!/bin/bash +set -o errexit +set -o pipefail + readonly homebrew_online='https://github.com/Homebrew' readonly repos_dir="$(mktemp -d)" readonly main_repo_dir="$(mktemp -d)" # From where files will be copied @@ -31,7 +34,15 @@ function copy_templates_and_ci { local repo_name repo_name="${1}" - rsync --archive --delete "${main_repo_dir}"/{.editorconfig,.gitattributes,.github,.gitignore,.travis.yml,ci,CODE_OF_CONDUCT.md} '.' + rsync --archive --prune-empty-dirs --delete \ + --include '.editorconfig' \ + --include '.gitattributes' \ + --include '.github/***' \ + --include '.gitignore' \ + --include '.travis.yml' \ + --include 'CODE_OF_CONDUCT.md' \ + --include 'ci/***' \ + --exclude '*' "${main_repo_dir}/" '.' rm '.github/ISSUE_TEMPLATE/02_feature_request.md' # Feature requests only make sense in the main repo /usr/bin/sed -i '' -E "s:homebrew-cask/(pulls|issues|search):${repo_name}/\1:" '.github/PULL_REQUEST_TEMPLATE.md' # PULL_REQUEST_TEMPLATE has repo-specific links } @@ -42,6 +53,7 @@ function push_changes { is_repo_changed="$(git status --porcelain --ignore-submodules=dirty 2> /dev/null)" if [[ -n "${is_repo_changed}" ]]; then git add --all # Stage everything so 'git diff' does not miss aything (like new paths) + for modified_path in $(git diff --name-only --staged); do echo -n "Detected changes to ${modified_path}. " git commit "${modified_path}" --message "$(basename "${modified_path}"): update to match main repo" --quiet