mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Merge pull request #7433 from prometheus/superq/force_sync
Update repo sync policies
This commit is contained in:
commit
08780a9ec9
|
@ -53,17 +53,30 @@ post_pull_request() {
|
|||
"https://api.github.com/repos/${1}/pulls"
|
||||
}
|
||||
|
||||
check_license() {
|
||||
# Check to see if the input is an Apache license of some kind
|
||||
echo "$1" | grep --quiet --no-messages --ignore-case 'Apache License'
|
||||
}
|
||||
|
||||
process_repo() {
|
||||
local org_repo="$1"
|
||||
echo -e "\e[32mAnalyzing '${org_repo}'\e[0m"
|
||||
|
||||
local needs_update=0
|
||||
local needs_update=()
|
||||
for source_file in ${SYNC_FILES}; do
|
||||
source_checksum="$(sha256sum "${source_dir}/${source_file}" | cut -d' ' -f1)"
|
||||
|
||||
target_file="$(curl -s --fail "https://raw.githubusercontent.com/${org_repo}/master/${source_file}")"
|
||||
if [[ "${source_file}" == 'LICENSE' ]] && ! check_license "${target_file}" ; then
|
||||
echo "LICENSE in ${org_repo} is not apache, skipping."
|
||||
continue
|
||||
fi
|
||||
if [[ -z "${target_file}" ]]; then
|
||||
echo "${source_file} doesn't exist in ${org_repo}"
|
||||
if [[ "${source_file}" == 'CODE_OF_CONDUCT.md' ]] ; then
|
||||
echo "CODE_OF_CONDUCT.md missing in ${org_repo}, force updating."
|
||||
needs_update+=('CODE_OF_CONDUCT.md')
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
target_checksum="$(echo "${target_file}" | sha256sum | cut -d' ' -f1)"
|
||||
|
@ -71,10 +84,10 @@ process_repo() {
|
|||
echo "${source_file} is already in sync."
|
||||
continue
|
||||
fi
|
||||
needs_update=1
|
||||
needs_update+=("${source_file}")
|
||||
done
|
||||
|
||||
if [[ "${needs_update}" -eq 0 ]] ; then
|
||||
if [[ "${#needs_update[@]}" -eq 0 ]] ; then
|
||||
echo "No files need sync."
|
||||
return
|
||||
fi
|
||||
|
@ -85,7 +98,7 @@ process_repo() {
|
|||
git checkout -b "${branch}" || return 1
|
||||
|
||||
# Update the files in target repo by one from prometheus/prometheus.
|
||||
for source_file in ${SYNC_FILES}; do
|
||||
for source_file in ${needs_update[@]}; do
|
||||
cp -f "${source_dir}/${source_file}" "./${source_file}"
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue