Return-Path: X-Original-To: apmail-corinthia-commits-archive@minotaur.apache.org Delivered-To: apmail-corinthia-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6149118A77 for ; Mon, 17 Aug 2015 19:31:37 +0000 (UTC) Received: (qmail 2653 invoked by uid 500); 17 Aug 2015 19:31:37 -0000 Delivered-To: apmail-corinthia-commits-archive@corinthia.apache.org Received: (qmail 2632 invoked by uid 500); 17 Aug 2015 19:31:37 -0000 Mailing-List: contact commits-help@corinthia.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@corinthia.incubator.apache.org Delivered-To: mailing list commits@corinthia.incubator.apache.org Received: (qmail 2623 invoked by uid 99); 17 Aug 2015 19:31:37 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2015 19:31:37 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 95AE41AA370 for ; Mon, 17 Aug 2015 19:31:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.795 X-Spam-Level: * X-Spam-Status: No, score=1.795 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.006, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id xLGlxZCtXmth for ; Mon, 17 Aug 2015 19:31:27 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id EECA420F4F for ; Mon, 17 Aug 2015 19:31:25 +0000 (UTC) Received: (qmail 2591 invoked by uid 99); 17 Aug 2015 19:31:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2015 19:31:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D23E4E01CA; Mon, 17 Aug 2015 19:31:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gbg@apache.org To: commits@corinthia.incubator.apache.org Message-Id: <7b0de1cb1f924913b427e8bbe91be0e7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-corinthia git commit: Local and Github (master) directory tree script Date: Mon, 17 Aug 2015 19:31:24 +0000 (UTC) Repository: incubator-corinthia Updated Branches: refs/heads/master 610fd50e2 -> e1d7c54eb Local and Github (master) directory tree script Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/e1d7c54e Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/e1d7c54e Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/e1d7c54e Branch: refs/heads/master Commit: e1d7c54ebb21659b92625a04114187708fca0741 Parents: 610fd50 Author: Gabriela Gibson Authored: Mon Aug 17 20:30:50 2015 +0100 Committer: Gabriela Gibson Committed: Mon Aug 17 20:30:50 2015 +0100 ---------------------------------------------------------------------- scripts/README.txt | 1 + scripts/check_tree.sh | 132 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e1d7c54e/scripts/README.txt ---------------------------------------------------------------------- diff --git a/scripts/README.txt b/scripts/README.txt index 1b26243..214ab5b 100644 --- a/scripts/README.txt +++ b/scripts/README.txt @@ -6,3 +6,4 @@ Current scripts: ---------------- build-corinthia-on-linux Fetch and build Corinthia with TAGS and/or tags files. +check_tree.sh Build local and github directory tree html files. http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e1d7c54e/scripts/check_tree.sh ---------------------------------------------------------------------- diff --git a/scripts/check_tree.sh b/scripts/check_tree.sh new file mode 100755 index 0000000..17cfd0a --- /dev/null +++ b/scripts/check_tree.sh @@ -0,0 +1,132 @@ +#! /bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +############################################################################# +# +# This script generates a directory tree html representation of the +# Corinthia project for the local file directory and the remote Github +# directory (master). +# +# It pulls down latest Corinthia version, makes the new tree, diffs it +# to the old tree and if the tree has changed, creates, commit and +# pushes the new trees. It uses the commit message to label the +# file's purpose. +# +# File created/updated: +# +# $TREE_FILE_NAME --- the tree that works for the local directory +# $GIT_TREE_FILE_NAME --- the tree that works for the remote repository +# +# This script is designed to run as a daily cronjob on one of the +# comitter's machines and it is assumed that their git setup has +# access to their server password. +# +# useage: ./checktree -w +# +# Current 'tree guardian': Gabriela +# +########################################################################## + +PROJECT_NAME="Corinthia" +TRUNK_PATH="/home/g/cor-tree-cronjob/incubator-corinthia/" +TREE_FILE_NAME="tree_local_directory.html" +GIT_TREE_FILE_NAME="tree_github_repository.html" +PROJECT_SERVER="apache.org" +LOG_FILE="CorinthiaTree.log" +MAX_RETRIES=20 +COUNT_TRIES=0 + +GIT_HUB_LINKS='s/href="./href=\"https:\/github.com\/apache\/incubator-corinthia\/tree\/master/g' + +WRITE=0 + +write_log() +{ + echo "$(date): $*." >> $LOG_FILE +} + +usage() +{ + echo "Only \"-w\" is a valid argument. Exiting" + exit +} + +update_tree() +{ + HAS_INET_CONNECTION=$(ping -c 1 $PROJECT_SERVER | grep -c "1 received") + + if [[ $HAS_INET_CONNECTION != 1 ]] + then + COUNT_TRIES=$(( COUNT_TRIES+1 )) + if [[ $MAX_RETRIES -gt $COUNT_TRIES ]] + then + $(sleep "3600s") + update_tree + else + write_log "Update failure" + fi + else + WANT_UPDATE=$(git pull) + if [ "$WANT_UPDATE" == "Already up-to-date." ]; + then + write_log "$WANT_UPDATE" + exit + else + tree -d > new_tree.html + NEED_TREE=$(diff new_tree.html old_tree.html) + if [[ -n $NEED_TREE ]] + then + mv new_tree.html old_tree.html + tree -d -H . -T "$PROJECT_NAME Local File Directory Structure" > $TREE_FILE_NAME + tree -d -H . -T "$PROJECT_NAME Github Current Repository Directory Structure" | + sed -e $GIT_HUB_LINKS > $GIT_TREE_FILE_NAME + if [[ $WRITE == 1 ]]; + then + git add $TREE_FILE_NAME + git commit -m "Local File Directory Structure" + git push + git add $GIT_TREE_FILE_NAME + git commit -m "Github Current Repository Directory Structure" + git push + write_log "Tree updated." + else + write_log "Tree not written, see useage." + fi + fi + fi + fi +} + +cd $TRUNK_PATH + +write_log "check_tree.sh: Activated" + +while getopts w opt; do + case "$opt" in + w) + WRITE=1 + ;; + *) + usage + esac +done + +update_tree + +exit