Add git worktree support to update script.

This commit is contained in:
Andrius Štikonas 2020-12-29 20:10:07 +00:00
parent 0986776b19
commit b97d173cc4
2 changed files with 46 additions and 41 deletions

66
update
View File

@ -17,36 +17,40 @@
source "$(dirname "$0")/variables" source "$(dirname "$0")/variables"
echo -e "Language: $RED$LCODE$ENDCOLOR" echo -e "Language: ${RED}${LCODE}${ENDCOLOR}"
for BRANCH in $BRANCHES; do for BRANCH in $BRANCHES; do
echo -e "Checking out files from $BLUE$BRANCH$ENDCOLOR" echo -e "Checking out files from ${BLUE}${BRANCH}${ENDCOLOR}"
if [ ! -e "$BRANCH" ]; then if [ ! -e "$BRANCH" ]; then
mkdir "$BRANCH" CURRENT_DIR="$PWD"
fi (
"$GIT" archive --remote "$REPO" --prefix="$BRANCH-temp/" --format=tar "$BRANCH:po" | tar x cd $LOCAL_REPO
for dir in $(ls "$BRANCH-temp/wesnoth"* -d); do git worktree add "${CURRENT_DIR}/${BRANCH}" "$BRANCH"
echo "Processing $(basename "$dir" | sed s/wesnoth-//).$LCODE.po" )
file="$BRANCH/$(basename "$dir" | sed s/wesnoth-//).$LCODE.po" fi
if [ -f "$dir""/$LCODE"".po" ]; then git archive --remote "$REPO" --prefix="${BRANCH}-temp/" --format=tar "${BRANCH}:po" | tar x
if [ -f "$file" ]; then for dir in $(ls "${BRANCH}-temp/wesnoth"* -d); do
echo -e "${BLUE}Merging:$ENDCOLOR" echo "Processing $(basename "$dir" | sed s/wesnoth-//).${LCODE}.po"
$MSGMERGE -U -v "$file" "$dir/$(basename "$dir").pot" file="${BRANCH}/$(basename "$dir" | sed s/wesnoth-//).${LCODE}.po"
rm -f "$file~" if [ -f "${dir}/${LCODE}.po" ]; then
else if [ -f "$file" ]; then
echo -e "${RED}Copying:$ENDCOLOR" echo -e "$BLUE""Merging:$ENDCOLOR"
cp "$dir/$LCODE.po" "$file" msgmerge -U -v "$file" "${dir}/$(basename "$dir").pot"
fi rm -f "$file~"
else else
if [ ! -f "$file" ]; then echo -e "${RED}Copying:${ENDCOLOR}"
echo -e "${RED}No po file in repository. Running msginit.$ENDCOLOR" cp "${dir}/${LCODE}.po" "$file"
echo "$dir" fi
"$MSGINIT" -i "$dir/$(basename "$dir").pot" -o "$file" else
else if [ ! -f "$file" ]; then
echo -e "${RED}No po file in repository. Found file in workspace.$ENDCOLOR" echo -e "${RED}No po file in repository. Running msginit.${ENDCOLOR}"
fi echo "$dir"
fi msginit -i "$dir/$(basename "$dir").pot" -o "$file"
echo "" else
done echo -e "${RED}No po file in repository. Found file in workspace.${ENDCOLOR}"
rm -rf "$BRANCH-temp" fi
fi
echo ""
done
rm -rf "${BRANCH}-temp"
done done
echo -e "${GREEN}Finished.$ENDCOLOR" echo -e "${GREEN}Finished.${ENDCOLOR}"

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# You would probably need to make some adjustments to variables. # You would probably need to make some adjustments to variables.
# Copyright (C) 2008 Andrius Štikonas <andrius@stikonas.eu> # Copyright (C) 2008 Andrius Štikonas <stikonas@gmail.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -17,7 +17,8 @@
# Repositories # Repositories
REPO="~/repositories/wesnoth" # preferably local clone but remote should work as well REPO="~/repositories/wesnoth" # preferably local clone but remote should work as well
BRANCHES="master" # one or multiple branches separated by space. LOCAL_REPO="git" # should be bare repository
BRANCHES="1.8 1.10 1.12 1.14 master" # one or multiple branches separated by space.
# Options # Options
LCODE="lt" # Language code. Only 1 language is supported. LCODE="lt" # Language code. Only 1 language is supported.
@ -26,14 +27,14 @@ LCODE="lt" # Language code. Only 1 language is supported.
MDIR="mo" MDIR="mo"
# Binaries. Don't forget to install them before usign these scripts. # Binaries. Don't forget to install them before usign these scripts.
GIT=$(command -v git 2> /dev/null) GIT=$(which git 2> /dev/null)
MSGFMT=$(command -v msgfmt 2> /dev/null) MSGFMT=$(which msgfmt 2> /dev/null)
MSGMERGE=$(command -v msgmerge 2> /dev/null) MSGMERGE=$(which msgmerge 2> /dev/null)
MSGINIT=$(command -v msginit 2> /dev/null) MSGINIT=$(which msginit 2> /dev/null)
ISUTF8=$(command -v isutf8 2> /dev/null) ISUTF8=$(which isutf8 2> /dev/null)
TAR=$(command -v tar 2> /dev/null) TAR=$(which tar 2> /dev/null)
BZIP=$(command -v bzip2 2> /dev/null) BZIP=$(which bzip2 2> /dev/null)
DIFF=$(command -v diff 2> /dev/null) DIFF=$(which diff 2> /dev/null)
# Colors # Colors
RED="\033[1;31m" RED="\033[1;31m"