Fix sync_templates_and_ci.

This commit is contained in:
Markus Reiter
2018-08-04 14:31:13 +02:00
parent 184a972b3e
commit fe87ae1b79
+13 -1
View File
@@ -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