Nikerabbit has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/326901 )
Change subject: repoupdate: Fix issues found by shellcheck
......................................................................
repoupdate: Fix issues found by shellcheck
* Add some quoting
* Use $() instead of ``
* Use $* instead of $@
* Guard against 'cd' failures
* Remove unused variable WIKI
* Remove unnecessary use of echo
In addition:
* Fixed a bug in doUpdate that prevented potlatch2 being updated
* Use checkVar for remaining variable checks
Change-Id: I5cbcfd40e04e95d8a7cd80ef969288c666c41882
---
M bin/repoupdate
1 file changed, 16 insertions(+), 31 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/translatewiki
refs/changes/01/326901/1
diff --git a/bin/repoupdate b/bin/repoupdate
index 1fb6d30..c93ec96 100755
--- a/bin/repoupdate
+++ b/bin/repoupdate
@@ -1,17 +1,16 @@
#!/bin/bash
set -u
-DIRSCRIPT="`dirname \"$0\"`"
-DIRSCRIPT="`( cd \"$DIRSCRIPT\" && pwd )`"
+DIRSCRIPT=$(dirname "$0")
+DIRSCRIPT=$(cd "$DIRSCRIPT" && pwd)
DIRLOG=/home/betawiki/logs/repo
PROJECT=$1
-WIKI=/srv/mediawiki/targets/production
-DIR="${2:-`pwd`}"
-source $DIRSCRIPT/findexportroot
-cd "$DIR"
+DIR=${2:-$(pwd)}
+source "$DIRSCRIPT/findexportroot"
+cd "$DIR" || exit
-echo "$(date --rfc-3339=seconds --utc) [$(whoami) at $DIR] $0 $@" >> $DIRLOG
+echo "$(date --rfc-3339=seconds --utc) [$(whoami) at $DIR] $0 $*" >> $DIRLOG
checkVar() {
if [ -z "${!1:-}" ]
@@ -26,7 +25,6 @@
VAR="REPO_$VAR"
checkVar "$VAR"
"$2" "${!VAR}" "$DIR/$1" "${3:-}"
- exit 0
}
# Ignore subrepos like Collection/OfflineContentGenerator
@@ -79,17 +77,13 @@
if [ "$PROJECT" = "fudforum" ]
then
- svn up -q $PROJECT
+ svn up -q "$PROJECT"
elif [ "$PROJECT" = "ihris" ]
then
- cd $PROJECT
+ cd "$PROJECT" || exit
for MODULE in $REPO_IHRIS_MODULES
- do
- cd $MODULE
- bzr pull -q
- cd ..
- done
+ do ( cd "$MODULE" && bzr pull -q ) done
elif [ "$PROJECT" = "mifos" ]
then
@@ -97,34 +91,25 @@
elif [ "$PROJECT" = "mediawiki" ]
then
- if [ -z "$REPO_MEDIAWIKI_BRANCHES" ]
- then echo "Add REPO_MEDIAWIKI_BRANCHES to REPOCONF"; exit 1
- fi
-
+ checkVar 'REPO_MEDIAWIKI_BRANCHES'
echo "$REPO_MEDIAWIKI_BRANCHES" | tr ' ' '\n' |
xargs -P4 -I___ "$CLUPDATE_GERRIT" "$REPO_MEDIAWIKI"
"$DIR/$PROJECT/___" "___"
elif [ "$PROJECT" = "mediawiki-extensions" ]
then
- if [ -z "$REPO_MWEXTGIT" ]
- then echo "Add REPO_MWEXTGIT to REPOCONF"; exit 1
- fi
-
- echo "$(fetchReposFromGerrit mediawiki/extensions/)" |
+ checkVar 'REPO_MWEXTGIT'
+ fetchReposFromGerrit mediawiki/extensions/ |
xargs -P4 -I___ "$CLUPDATE_GERRIT" "$REPO_MWEXTGIT/___.git"
"$DIR/$PROJECT/extensions/___"
elif [ "$PROJECT" = "mediawiki-skins" ]
then
- if [ -z "$REPO_MWSKINGIT" ]
- then echo "Add REPO_MWSKINGIT to REPOCONF"; exit 1
- fi
-
- echo "$(fetchReposFromGerrit mediawiki/skins/)" |
+ checkVar 'REPO_MWSKINGIT'
+ fetchReposFromGerrit mediawiki/skins/ |
xargs -P4 -I___ "$CLUPDATE_GERRIT" "$REPO_MWSKINGIT/___.git"
"$DIR/$PROJECT/___"
elif [ "$PROJECT" = "nocc" ]
then
- svn up -q $PROJECT
+ svn up -q "$PROJECT"
elif [ "$PROJECT" = "osm" ]
then
@@ -132,6 +117,6 @@
doUpdate "potlatch2" "$CLUPDATE"
else
- echo "`basename $0`: Unknown project"
+ echo "$(basename "$0"): Unknown project"
exit 1
fi
--
To view, visit https://gerrit.wikimedia.org/r/326901
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5cbcfd40e04e95d8a7cd80ef969288c666c41882
Gerrit-PatchSet: 1
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits