@ -53,17 +53,30 @@ post_pull_request() {
" https://api.github.com/repos/ ${ 1 } /pulls "
" 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( ) {
process_repo( ) {
local org_repo = " $1 "
local org_repo = " $1 "
echo -e " \e[32mAnalyzing ' ${ org_repo } '\e[0m "
echo -e " \e[32mAnalyzing ' ${ org_repo } '\e[0m "
local needs_update = 0
local needs_update = ( )
for source_file in ${ SYNC_FILES } ; do
for source_file in ${ SYNC_FILES } ; do
source_checksum = " $( sha256sum " ${ source_dir } / ${ source_file } " | cut -d' ' -f1) "
source_checksum = " $( sha256sum " ${ source_dir } / ${ source_file } " | cut -d' ' -f1) "
target_file = " $( curl -s --fail " https://raw.githubusercontent.com/ ${ org_repo } /master/ ${ source_file } " ) "
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
if [ [ -z " ${ target_file } " ] ] ; then
echo " ${ source_file } doesn't exist in ${ org_repo } "
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
continue
fi
fi
target_checksum = " $( echo " ${ target_file } " | sha256sum | cut -d' ' -f1) "
target_checksum = " $( echo " ${ target_file } " | sha256sum | cut -d' ' -f1) "
@ -71,10 +84,10 @@ process_repo() {
echo " ${ source_file } is already in sync. "
echo " ${ source_file } is already in sync. "
continue
continue
fi
fi
needs_update = 1
needs_update += ( " ${ source_file } " )
done
done
if [ [ " ${ needs_update } " -eq 0 ] ] ; then
if [ [ " ${# needs_update [@] } " -eq 0 ] ] ; then
echo "No files need sync."
echo "No files need sync."
return
return
fi
fi
@ -85,7 +98,7 @@ process_repo() {
git checkout -b " ${ branch } " || return 1
git checkout -b " ${ branch } " || return 1
# Update the files in target repo by one from prometheus/prometheus.
# 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 } "
cp -f " ${ source_dir } / ${ source_file } " " ./ ${ source_file } "
done
done