diff --git a/.travis.yml b/.travis.yml index ab0090fa5a..0b12ca6653 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,27 @@ -language: c +language: minimal +install: + - sudo apt-get install jq + - git clone --depth=1 -b gh-pages https://github.com/LCTT/TranslateProject/ build && rm -rf build/.git script: - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sh ./scripts/check.sh; fi' - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sh ./scripts/badge.sh; fi' + - 'if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then sh ./scripts/status.sh; fi' + branches: only: - master + # - status except: - gh-pages git: submodules: false + depth: false deploy: provider: pages skip_cleanup: true github_token: $GITHUB_TOKEN local_dir: build on: - branch: master + branch: + - master + # - status diff --git a/scripts/status.sh b/scripts/status.sh new file mode 100755 index 0000000000..f3cc4b8d82 --- /dev/null +++ b/scripts/status.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# 重新生成badge +set -o errexit + +SCRIPTS_DIR=$(cd $(dirname "$0") && pwd) +BUILD_DIR=$(cd $SCRIPTS_DIR/.. && pwd)/build +mkdir -p ${BUILD_DIR}/status +${SCRIPTS_DIR}/status/status.sh > ${BUILD_DIR}/status/status.json diff --git a/scripts/status/status.sh b/scripts/status/status.sh index 9bb5aaf700..acb03bbf4e 100755 --- a/scripts/status/status.sh +++ b/scripts/status/status.sh @@ -13,12 +13,15 @@ function get_status_of() git log --date=short --pretty=format:"{\"file\":\"${file}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "${file}" } -( -git grep -niE "translat|fanyi|翻译" sources/*.md |awk -F ":" '{if ($2<=3) print $1}' |xargs -I{} git log --date=short --pretty=format:"{\"filename\":\"{}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "{}"|jq --slurp - +translating=$( git grep -niE "translat|fanyi|翻译" sources/*.md |awk -F ":" '{if ($2<=3) print $1}' |xargs -I{} git log --date=short --pretty=format:"{\"filename\":\"{}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "{}") +unselected=$( find sources -name "2*.md"|sort|while read file;do if ! file-translating-p "${file}";then get_status_of "${file}" fi -done |jq --slurp -)|jq --slurp '{"translating":.[0],"unselected":.[1]}' +done +) +( +echo ${translating}|jq -s "." +echo ${unselected} |jq -s "." +)|jq -s '{"translating":.[0],"unselected":.[1]}'