diff --git a/missions/contrib/00_git_shared/Makefile b/missions/contrib/00_git_shared/Makefile new file mode 100644 index 000000000..2c0c50167 --- /dev/null +++ b/missions/contrib/00_git_shared/Makefile @@ -0,0 +1,41 @@ +SH_FILES=$(wildcard *.sh) +EXCEPTIONS= +OTHER_FILES= + +LANGUAGES=$(wildcard i18n/*.po) +LANGUAGES:=$(filter-out i18n/en.po, $(LANGUAGES)) +SH_FILES:=$(filter-out $(EXCEPTIONS), $(SH_FILES)) +SORT= +OPTIONS=--indent --no-wrap --no-location + +all: i18n/en.po $(LANGUAGES) + +add-locations: SORT=--add-location --sort-by-file +add-locations: all + +i18n/en.po: i18n/template.pot FORCE + @echo "msgen $@" + @msgen $(OPTIONS) $(SORT) i18n/template.pot --output=$@ + @echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" | cat - $@ > $@~ + @mv $@~ $@ + +$(LANGUAGES):%.po: i18n/template.pot FORCE + @echo "msgmerge $@" + @msgmerge --update $(OPTIONS) $(SORT) $@ i18n/template.pot + +i18n/template.pot: $(SH_FILES) $(OTHER_FILES) FORCE + @mkdir -p i18n/ + @echo "generating i18n/template.pot" + @xgettext --from-code=UTF-8 --omit-header $(OPTIONS) $(SORT) --join-existing --output i18n/template.pot $(SH_FILES) $(OTHER_FILES) + @echo "done" + +new: i18n/template.pot + @read -p "language code: " lang; \ + [ -e "./i18n/$$lang.po" ] && echo "file i18n/$$lang.po already exists" && exit; \ + echo "file i18n/$$lang.po created"; \ + msgcat $(OPTIONS) --output i18n/$$lang.po i18n/template.pot + +clean: + rm -f i18n/*~ + +.PHONY: all clean new FORCE diff --git a/missions/contrib/00_git_shared/gitconfig b/missions/contrib/00_git_shared/gitconfig new file mode 100644 index 000000000..c2aec0e45 --- /dev/null +++ b/missions/contrib/00_git_shared/gitconfig @@ -0,0 +1,7 @@ +# default git config file for GameShell-git missions + +[core] + editor = nano + +[init] + defaultBranch = main diff --git a/missions/contrib/00_git_shared/gshrc b/missions/contrib/00_git_shared/gshrc new file mode 100644 index 000000000..185e8009c --- /dev/null +++ b/missions/contrib/00_git_shared/gshrc @@ -0,0 +1,19 @@ +#!/usr/bin/env sh + +# add CWD in the prompt, as in the third mission from standard GameShell +case "$GSH_SHELL" in + *bash) + export PS1=' +\w +[mission $(gsh pcm)] $ ' + ;; + *zsh) + export PS1=' +%~ +[mission $(gsh pcm)] $ ' + ;; +esac + + +# prevent git from going above $GSH_ROOT when searching for enclosing git repo +export GIT_CEILING_DIRECTORIES=$GSH_ROOT diff --git a/missions/contrib/00_git_shared/i18n/en.po b/missions/contrib/00_git_shared/i18n/en.po new file mode 100644 index 000000000..ee131abf7 --- /dev/null +++ b/missions/contrib/00_git_shared/i18n/en.po @@ -0,0 +1,16 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=ASCII\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "$MISSION_DIR/treasure-msg/en.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "$MISSION_DIR/skip/en.txt" diff --git a/missions/contrib/00_git_shared/i18n/fr.po b/missions/contrib/00_git_shared/i18n/fr.po new file mode 100644 index 000000000..2316aeb58 --- /dev/null +++ b/missions/contrib/00_git_shared/i18n/fr.po @@ -0,0 +1,15 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" diff --git a/missions/contrib/00_git_shared/i18n/template.pot b/missions/contrib/00_git_shared/i18n/template.pot new file mode 100644 index 000000000..2316aeb58 --- /dev/null +++ b/missions/contrib/00_git_shared/i18n/template.pot @@ -0,0 +1,15 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" diff --git a/missions/contrib/TODO.md b/missions/contrib/TODO.md new file mode 100644 index 000000000..ef4cf1063 --- /dev/null +++ b/missions/contrib/TODO.md @@ -0,0 +1,18 @@ + + - [x] should we use `git switch` or `git checkout` => `git switch` + - [ ] should we use `HEAD` or `@`, or both + - [ ] create one or two "big" existing repositories (with several branches and commits) for some of the advanced missions + + - [ ] discuss use of "git vocabulary" (directory vs repository, tracked vs untracked, index area, etc) vs "lore vocabulary" + + - [ ] check if I can deal with dependencies (eg, nano) from inside a dummy mission (00_git_shared) + + - [ ] add some git specific aliases as `treasure.sh` files, for example + - `gs => git status` + - `gl => git log --oneline` + - `gll => git log --stat` + - `gg => git log --all --decorate --oneline --graph` + NOTE: I'm not sure that there is any advantage using "git aliases" (git + config --global alias.ALIAS ...) + + diff --git a/missions/contrib/git.idx b/missions/contrib/git.idx new file mode 100644 index 000000000..1b9bb7f00 --- /dev/null +++ b/missions/contrib/git.idx @@ -0,0 +1,7 @@ + !00_git_shared + git_basics/01_init + git_basics/02_create_file + git_basics/03_add + git_basics/00_config + git_basics/04_commit + ../FINAL_MISSION diff --git a/missions/contrib/git_basics/00_config/Makefile b/missions/contrib/git_basics/00_config/Makefile new file mode 100644 index 000000000..2c0c50167 --- /dev/null +++ b/missions/contrib/git_basics/00_config/Makefile @@ -0,0 +1,41 @@ +SH_FILES=$(wildcard *.sh) +EXCEPTIONS= +OTHER_FILES= + +LANGUAGES=$(wildcard i18n/*.po) +LANGUAGES:=$(filter-out i18n/en.po, $(LANGUAGES)) +SH_FILES:=$(filter-out $(EXCEPTIONS), $(SH_FILES)) +SORT= +OPTIONS=--indent --no-wrap --no-location + +all: i18n/en.po $(LANGUAGES) + +add-locations: SORT=--add-location --sort-by-file +add-locations: all + +i18n/en.po: i18n/template.pot FORCE + @echo "msgen $@" + @msgen $(OPTIONS) $(SORT) i18n/template.pot --output=$@ + @echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" | cat - $@ > $@~ + @mv $@~ $@ + +$(LANGUAGES):%.po: i18n/template.pot FORCE + @echo "msgmerge $@" + @msgmerge --update $(OPTIONS) $(SORT) $@ i18n/template.pot + +i18n/template.pot: $(SH_FILES) $(OTHER_FILES) FORCE + @mkdir -p i18n/ + @echo "generating i18n/template.pot" + @xgettext --from-code=UTF-8 --omit-header $(OPTIONS) $(SORT) --join-existing --output i18n/template.pot $(SH_FILES) $(OTHER_FILES) + @echo "done" + +new: i18n/template.pot + @read -p "language code: " lang; \ + [ -e "./i18n/$$lang.po" ] && echo "file i18n/$$lang.po already exists" && exit; \ + echo "file i18n/$$lang.po created"; \ + msgcat $(OPTIONS) --output i18n/$$lang.po i18n/template.pot + +clean: + rm -f i18n/*~ + +.PHONY: all clean new FORCE diff --git a/missions/contrib/git_basics/00_config/auto.sh b/missions/contrib/git_basics/00_config/auto.sh new file mode 100644 index 000000000..0fe1f86c5 --- /dev/null +++ b/missions/contrib/git_basics/00_config/auto.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +git config --global user.name "auto user.name Gameshell-Git" +git config --global user.email auto@user.email.gameshell.git +gsh check diff --git a/missions/contrib/git_basics/00_config/check.sh b/missions/contrib/git_basics/00_config/check.sh new file mode 100644 index 000000000..731a6b247 --- /dev/null +++ b/missions/contrib/git_basics/00_config/check.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +_mission_check() { + if ! git config --global user.name > /dev/null + then + echo "$(eval_gettext "You haven't configured your name.")" + rm -f "$GSH_HOME/.gitconfig" + return 1 + fi + + if ! git config --global user.email > /dev/null + then + echo "$(eval_gettext "You haven't configured your email.")" + rm -f "$GSH_HOME/.gitconfig" + return 1 + fi + + # save git config file for restoring + cp "$GSH_HOME/.gitconfig" "$GSH_TMP/gitconfig" + + return 0 +} +_mission_check diff --git a/missions/contrib/git_basics/00_config/goal.sh b/missions/contrib/git_basics/00_config/goal.sh new file mode 100644 index 000000000..b0b2bf611 --- /dev/null +++ b/missions/contrib/git_basics/00_config/goal.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +cat "$(eval_gettext '$MISSION_DIR/goal/en.txt')" + +if [ -f "$REAL_HOME/.gitconfig" ] +then + sed -e "s/\\\$REAL_USER/$(whoami)/g" "$(eval_gettext '$MISSION_DIR/goal/en-gitinit.txt')" +fi diff --git a/missions/contrib/git_basics/00_config/goal/en-gitinit.txt b/missions/contrib/git_basics/00_config/goal/en-gitinit.txt new file mode 100644 index 000000000..7ea2482f7 --- /dev/null +++ b/missions/contrib/git_basics/00_config/goal/en-gitinit.txt @@ -0,0 +1,8 @@ + + +Remark +====== + +Because GameShell runs in a modified environment, you need to do this step +even if git is already configured on your standard account (user +'$REAL_USER'). diff --git a/missions/contrib/git_basics/00_config/goal/en.txt b/missions/contrib/git_basics/00_config/goal/en.txt new file mode 100644 index 000000000..6e1bf357a --- /dev/null +++ b/missions/contrib/git_basics/00_config/goal/en.txt @@ -0,0 +1,18 @@ +Mission goal +============ + +The magic concil wants to keep a record of all modifications made to the +library. For safety reasons, they also want to keep track of who has made +changes. + +Configure your identity so that git can include it whenever necessary. + + +Useful commands +=============== + +git config --global user.name "FIRSTNAME LASTNAME" + Save your name in a global git configuration file. + +git config --global user.email ME@EMAIL.GSH + Save your email in a global git configuration file. diff --git a/missions/contrib/git_basics/00_config/goal/fr-gitinit.txt b/missions/contrib/git_basics/00_config/goal/fr-gitinit.txt new file mode 100644 index 000000000..9ca39fb7e --- /dev/null +++ b/missions/contrib/git_basics/00_config/goal/fr-gitinit.txt @@ -0,0 +1,9 @@ + + +Remarque +======== + +Comme GameShell est exécuté dans un environnement modifié, vous devez faire +cette étape même si git est déjà configuré pour votre compte habituel +(utilisateur '$REAL_USER'). + diff --git a/missions/contrib/git_basics/00_config/goal/fr.txt b/missions/contrib/git_basics/00_config/goal/fr.txt new file mode 100644 index 000000000..bb3460a48 --- /dev/null +++ b/missions/contrib/git_basics/00_config/goal/fr.txt @@ -0,0 +1,14 @@ +Objectif +======== + +blabla + + +Commandes utiles +================ + +git config --global user.name "PRENOM NOM" + Sauvegarde votre nom dans un fichier de configuration git global. + +git config --global user.email MOI@EMAIL.GSH + Sauvegarde votre email dans un fichier de configuration git global. diff --git a/missions/contrib/git_basics/00_config/i18n/en.po b/missions/contrib/git_basics/00_config/i18n/en.po new file mode 100644 index 000000000..4b1380d7b --- /dev/null +++ b/missions/contrib/git_basics/00_config/i18n/en.po @@ -0,0 +1,29 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=ASCII\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "$MISSION_DIR/skip/en.txt" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "$MISSION_DIR/treasure-msg/en.txt" + +#, sh-format +msgid "$MISSION_DIR/goal/en-gitinit.txt" +msgstr "$MISSION_DIR/goal/en-gitinit.txt" + +#, sh-format +msgid "You haven't configured your name." +msgstr "You haven't configured your name." + +#, sh-format +msgid "You haven't configured your email." +msgstr "You haven't configured your email." diff --git a/missions/contrib/git_basics/00_config/i18n/fr.po b/missions/contrib/git_basics/00_config/i18n/fr.po new file mode 100644 index 000000000..130f4717a --- /dev/null +++ b/missions/contrib/git_basics/00_config/i18n/fr.po @@ -0,0 +1,28 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/fr.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +#, sh-format +msgid "$MISSION_DIR/goal/en-gitinit.txt" +msgstr "$MISSION_DIR/goal/fr-gitinit.txt" + +#, sh-format +msgid "You haven't configured your name." +msgstr "Vous n'avez pas configuré votre nom." + +#, sh-format +msgid "You haven't configured your email." +msgstr "Vous n'avez pas configuré votre email." diff --git a/missions/contrib/git_basics/00_config/i18n/template.pot b/missions/contrib/git_basics/00_config/i18n/template.pot new file mode 100644 index 000000000..7aa6e9db4 --- /dev/null +++ b/missions/contrib/git_basics/00_config/i18n/template.pot @@ -0,0 +1,28 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +#, sh-format +msgid "$MISSION_DIR/goal/en-gitinit.txt" +msgstr "" + +#, sh-format +msgid "You haven't configured your name." +msgstr "" + +#, sh-format +msgid "You haven't configured your email." +msgstr "" diff --git a/missions/contrib/git_basics/01_init/Makefile b/missions/contrib/git_basics/01_init/Makefile new file mode 100644 index 000000000..2c0c50167 --- /dev/null +++ b/missions/contrib/git_basics/01_init/Makefile @@ -0,0 +1,41 @@ +SH_FILES=$(wildcard *.sh) +EXCEPTIONS= +OTHER_FILES= + +LANGUAGES=$(wildcard i18n/*.po) +LANGUAGES:=$(filter-out i18n/en.po, $(LANGUAGES)) +SH_FILES:=$(filter-out $(EXCEPTIONS), $(SH_FILES)) +SORT= +OPTIONS=--indent --no-wrap --no-location + +all: i18n/en.po $(LANGUAGES) + +add-locations: SORT=--add-location --sort-by-file +add-locations: all + +i18n/en.po: i18n/template.pot FORCE + @echo "msgen $@" + @msgen $(OPTIONS) $(SORT) i18n/template.pot --output=$@ + @echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" | cat - $@ > $@~ + @mv $@~ $@ + +$(LANGUAGES):%.po: i18n/template.pot FORCE + @echo "msgmerge $@" + @msgmerge --update $(OPTIONS) $(SORT) $@ i18n/template.pot + +i18n/template.pot: $(SH_FILES) $(OTHER_FILES) FORCE + @mkdir -p i18n/ + @echo "generating i18n/template.pot" + @xgettext --from-code=UTF-8 --omit-header $(OPTIONS) $(SORT) --join-existing --output i18n/template.pot $(SH_FILES) $(OTHER_FILES) + @echo "done" + +new: i18n/template.pot + @read -p "language code: " lang; \ + [ -e "./i18n/$$lang.po" ] && echo "file i18n/$$lang.po already exists" && exit; \ + echo "file i18n/$$lang.po created"; \ + msgcat $(OPTIONS) --output i18n/$$lang.po i18n/template.pot + +clean: + rm -f i18n/*~ + +.PHONY: all clean new FORCE diff --git a/missions/contrib/git_basics/01_init/auto.sh b/missions/contrib/git_basics/01_init/auto.sh new file mode 100644 index 000000000..ab5ebe27c --- /dev/null +++ b/missions/contrib/git_basics/01_init/auto.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +spellbook=$(eval_gettext "\$GSH_HOME/Castle/Lab/")/$(eval_gettext "Spellbook") +mkdir -p "$spellbook" +cd "$spellbook" +unset spellbook +git init +gsh check diff --git a/missions/contrib/git_basics/01_init/check.sh b/missions/contrib/git_basics/01_init/check.sh new file mode 100644 index 000000000..92127d56b --- /dev/null +++ b/missions/contrib/git_basics/01_init/check.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +_mission_check() { + spellbook=$(eval_gettext "Spellbook") + repo=$(readlink-f "$(eval_gettext "\$GSH_HOME/Castle/Lab/")/$spellbook") + current=$(readlink-f "$PWD") + + if [ "$(basename "$(pwd)")" != "$(eval_gettext "Spellbook")" ] + then + echo "$(eval_gettext 'You are not in the $spellbook directory.')" + # remove all Spellbook directories + find "$GSH_HOME" -iname "$spellbook" -print0 | xargs -0 rm -rf + return 1 + elif [ "$repo" != "$current" ] + then + echo "$(eval_gettext 'Your $spellbook directory is not in the Lab directory.')" + + # remove all Spellbook directories + echo "$(gettext 'You are teleported back to the initial directory.')" + cd $GSH_HOME + find "$GSH_HOME" -iname "$spellbook" -print0 | xargs -0 rm -rf + return 1 + elif ! git -C "$repo" rev-parse --is-inside-work-tree >/dev/null 2>&1 + then + echo "$(eval_gettext 'Your $spellbook directory is not a git repository.')" + return 1 + else + # TODO: should we check the directory is empty and fail otherwise? + return 0 + fi +} +_mission_check diff --git a/missions/contrib/git_basics/01_init/goal/en.txt b/missions/contrib/git_basics/01_init/goal/en.txt new file mode 100644 index 000000000..859f26b5f --- /dev/null +++ b/missions/contrib/git_basics/01_init/goal/en.txt @@ -0,0 +1,16 @@ +Mission goal +============ + +You are tasked with experimenting with spells in order to fight the dragon. To +keep track of you experiments, create a directory called `Spellbook` in the +`Lab` and make it into a git repository. + + +Useful commands +=============== + +mkdir DIRECTORY + Create a new directory inside the current directory. + +git init + Make the current directory into a git repository. diff --git a/missions/contrib/git_basics/01_init/goal/fr.txt b/missions/contrib/git_basics/01_init/goal/fr.txt new file mode 100644 index 000000000..e579a6b86 --- /dev/null +++ b/missions/contrib/git_basics/01_init/goal/fr.txt @@ -0,0 +1,14 @@ +Objectif +======== + +blabla + + +commandes utiles +================ + +mkdir REPERTOIRE + Crée un nouveau répertoire dans le répertoire courant. + +git init + Fait du répertoire courant un dépot git. diff --git a/missions/contrib/git_basics/01_init/i18n/en.po b/missions/contrib/git_basics/01_init/i18n/en.po new file mode 100644 index 000000000..38d2b4996 --- /dev/null +++ b/missions/contrib/git_basics/01_init/i18n/en.po @@ -0,0 +1,41 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=ASCII\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +# path for the text file containing the treasure message +#, sh-format +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "$MISSION_DIR/treasure-msg/en.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "$MISSION_DIR/skip/en.txt" + +#, sh-format +msgid "Spellbook" +msgstr "Spellbook" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/" +msgstr "$GSH_HOME/Castle/Lab/" + +msgid "You are teleported back to the initial directory." +msgstr "You are teleported back to the initial directory." + +#, sh-format +msgid "You are not in the $spellbook directory." +msgstr "You are not in the $spellbook directory." + +#, sh-format +msgid "Your $spellbook directory is not in the Lab directory." +msgstr "Your $spellbook directory is not in the Lab directory." + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "Your $spellbook directory is not a git repository." diff --git a/missions/contrib/git_basics/01_init/i18n/fr.po b/missions/contrib/git_basics/01_init/i18n/fr.po new file mode 100644 index 000000000..90d23dae0 --- /dev/null +++ b/missions/contrib/git_basics/01_init/i18n/fr.po @@ -0,0 +1,40 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/fr.txt" + +# path for the text file containing the treasure message +#, sh-format +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +#, sh-format +msgid "Spellbook" +msgstr "Grimoire" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/" +msgstr "$GSH_HOME/Chateau/Labo/" + +msgid "You are teleported back to the initial directory." +msgstr "Vous êtes téléporté dans le répertoire initial." + +#, sh-format +msgid "You are not in the $spellbook directory." +msgstr "Vous n'êtes pas dans le répertoire $spellbook." + +#, sh-format +msgid "Your $spellbook directory is not in the Lab directory." +msgstr "Votre répertoire $spellbook n'est pas dans le répertoire Labo." + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "Votre répertoire $spellbook n'est pas un dépot git." diff --git a/missions/contrib/git_basics/01_init/i18n/template.pot b/missions/contrib/git_basics/01_init/i18n/template.pot new file mode 100644 index 000000000..6a1611881 --- /dev/null +++ b/missions/contrib/git_basics/01_init/i18n/template.pot @@ -0,0 +1,56 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +# path for the text file containing the treasure message +#, sh-format +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +#, sh-format +msgid "Spellbook" +msgstr "" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/" +msgstr "" + +#, sh-format +msgid "You are not in the $spellbook directory" +msgstr "" + +#, sh-format +msgid "Your $spellbook directory is not in the Lab directory" +msgstr "" + +#, sh-format +msgid "Your $spellbook directory is not a git repository" +msgstr "" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab" +msgstr "" + +msgid "You are teleported back to the initial directory." +msgstr "" + +#, sh-format +msgid "You are not in the $spellbook directory." +msgstr "" + +#, sh-format +msgid "Your $spellbook directory is not in the Lab directory." +msgstr "" + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "" diff --git a/missions/contrib/git_basics/01_init/static.sh b/missions/contrib/git_basics/01_init/static.sh new file mode 100644 index 000000000..c869866a2 --- /dev/null +++ b/missions/contrib/git_basics/01_init/static.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +mkdir -p "$(eval_gettext "\$GSH_HOME/Castle/Lab")" diff --git a/missions/contrib/git_basics/01_init/test.sh b/missions/contrib/git_basics/01_init/test.sh new file mode 100644 index 000000000..1d50272c4 --- /dev/null +++ b/missions/contrib/git_basics/01_init/test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +spellbook=$(eval_gettext "Spellbook") +lab=$(eval_gettext "\$GSH_HOME/Castle/Lab/") + +cd +gsh assert check false + +mkdir "$spellbook" +gsh assert check false + +mkdir "$spellbook" +cd "$spellbook" +gsh assert check false + +mkdir "$lab/$spellbook" +cd "$lab/$spellbook" +gsh assert check false + +git init +gsh assert check true + +unset lab spellbook diff --git a/missions/contrib/git_basics/02_create_file/Makefile b/missions/contrib/git_basics/02_create_file/Makefile new file mode 100644 index 000000000..2c0c50167 --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/Makefile @@ -0,0 +1,41 @@ +SH_FILES=$(wildcard *.sh) +EXCEPTIONS= +OTHER_FILES= + +LANGUAGES=$(wildcard i18n/*.po) +LANGUAGES:=$(filter-out i18n/en.po, $(LANGUAGES)) +SH_FILES:=$(filter-out $(EXCEPTIONS), $(SH_FILES)) +SORT= +OPTIONS=--indent --no-wrap --no-location + +all: i18n/en.po $(LANGUAGES) + +add-locations: SORT=--add-location --sort-by-file +add-locations: all + +i18n/en.po: i18n/template.pot FORCE + @echo "msgen $@" + @msgen $(OPTIONS) $(SORT) i18n/template.pot --output=$@ + @echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" | cat - $@ > $@~ + @mv $@~ $@ + +$(LANGUAGES):%.po: i18n/template.pot FORCE + @echo "msgmerge $@" + @msgmerge --update $(OPTIONS) $(SORT) $@ i18n/template.pot + +i18n/template.pot: $(SH_FILES) $(OTHER_FILES) FORCE + @mkdir -p i18n/ + @echo "generating i18n/template.pot" + @xgettext --from-code=UTF-8 --omit-header $(OPTIONS) $(SORT) --join-existing --output i18n/template.pot $(SH_FILES) $(OTHER_FILES) + @echo "done" + +new: i18n/template.pot + @read -p "language code: " lang; \ + [ -e "./i18n/$$lang.po" ] && echo "file i18n/$$lang.po already exists" && exit; \ + echo "file i18n/$$lang.po created"; \ + msgcat $(OPTIONS) --output i18n/$$lang.po i18n/template.pot + +clean: + rm -f i18n/*~ + +.PHONY: all clean new FORCE diff --git a/missions/contrib/git_basics/02_create_file/auto.sh b/missions/contrib/git_basics/02_create_file/auto.sh new file mode 100644 index 000000000..d885a0d11 --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/auto.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +spell=$(eval_gettext '$GSH_HOME/Castle/Library')/$(gettext "glowing_finger.spl") +repo="$(eval_gettext '$GSH_HOME/Castle/Lab/Spellbook')" +cp "$spell" "$repo" +unset spell repo +gsh check diff --git a/missions/contrib/git_basics/02_create_file/check.sh b/missions/contrib/git_basics/02_create_file/check.sh new file mode 100644 index 000000000..2384b8717 --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/check.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +_mission_check() { + spell=$(gettext "glowing_finger.spl") + repo=$(eval_gettext '$GSH_HOME/Castle/Lab/Spellbook') + spellbook=$(basename "$repo") + + if ! git -C "$repo" rev-parse --is-inside-work-tree + then + echo "$(eval_gettext 'Your $spellbook directory is not a git repository.')" + return 1 + fi + + if [ ! -f "$repo/$spell" ] + then + echo $(eval_gettext "The Glowing Finger spell scroll isn't in your \$spellbook repository.") + return 1 + fi + + # TODO: should we check for other files, staged or not and fail? + + if ! git -C "$repo" status --porcelain | grep "^?? $spell" >/dev/null 2>&1 + then + echo $(eval_gettext 'The Glowing Finger spell scroll has already been registered into to your $spellbook repository!') + # TODO: what should we do here? + # we could git rm --cached the file + # but what if it has been commited? Should we reset the repo? + return 1 + fi + return 0 +} +_mission_check diff --git a/missions/contrib/git_basics/02_create_file/glowing_finger.spl b/missions/contrib/git_basics/02_create_file/glowing_finger.spl new file mode 100644 index 000000000..21863f84c --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/glowing_finger.spl @@ -0,0 +1,7 @@ +Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod +tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, +quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo +consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse +cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non +proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + diff --git a/missions/contrib/git_basics/02_create_file/goal/en.txt b/missions/contrib/git_basics/02_create_file/goal/en.txt new file mode 100644 index 000000000..9a1afe918 --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/goal/en.txt @@ -0,0 +1,27 @@ +Mission goal +============ + +Your first experiment will involve the "Glowing Finger" spell. It is +especially usefull when you don't have a torch closeby. + +The castle's library contains a scroll with the list of ingredients required +to cast the "Glowing Finger" spell. + +You must copy the Glowing Finger scroll from the Castle's Library into your +spellbook repository. + +You should check the status of this new file: it is //untracked// by git. + + +Useful commands +=============== + +git status + Show the state of the working repository. + + +Remark +====== + +If you are already familiar with git, **do not 'add' or 'commit'** the new +file. diff --git a/missions/contrib/git_basics/02_create_file/goal/fr.txt b/missions/contrib/git_basics/02_create_file/goal/fr.txt new file mode 100644 index 000000000..867ab5ed8 --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/goal/fr.txt @@ -0,0 +1,18 @@ +Objectif +======== + +blabla + + +Commandes utiles +================ + +git status + Affiche l'état du dépot courant. + + +Remarque +======== + +Si vous êtes déjà familier avec git, **ne faites pas de 'add' ou de 'commit'** +pour le nouveau fichier. diff --git a/missions/contrib/git_basics/02_create_file/i18n/en.po b/missions/contrib/git_basics/02_create_file/i18n/en.po new file mode 100644 index 000000000..ac4a1623c --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/i18n/en.po @@ -0,0 +1,35 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=ASCII\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +#, sh-format +msgid "$GSH_HOME/Castle/Library" +msgstr "$GSH_HOME/Castle/Library" + +msgid "glowing_finger.spl" +msgstr "glowing_finger.spl" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "$GSH_HOME/Castle/Lab/Spellbook" + +msgid "The Glowing Finger spell scroll isn't in your spellbook." +msgstr "The Glowing Finger spell scroll isn't in your spellbook." + +#, sh-format +msgid "$GSH_HOME/Castle/Lab" +msgstr "$GSH_HOME/Castle/Lab" + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "Your $spellbook directory is not a git repository." + +#, sh-format +msgid "The Glowing Finger spell scroll has already been registered into to your $spellbook repository!" +msgstr "The Glowing Finger spell scroll has already been registered into to your $spellbook repository!" diff --git a/missions/contrib/git_basics/02_create_file/i18n/fr.po b/missions/contrib/git_basics/02_create_file/i18n/fr.po new file mode 100644 index 000000000..cc5e7e969 --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/i18n/fr.po @@ -0,0 +1,34 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/fr.txt" + +#, sh-format +msgid "$GSH_HOME/Castle/Library" +msgstr "$GSH_HOME/Chateau/Bibliotheque" + +msgid "glowing_finger.spl" +msgstr "doigt_lumineux.srt" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "$GSH_HOME/Chateau/Labo/Grimoire" + +msgid "The Glowing Finger spell scroll isn't in your spellbook." +msgstr "Le parchemin du sortilège du Doigt Lumineux n'est pas dans votre grimoire." + +#, sh-format +msgid "$GSH_HOME/Castle/Lab" +msgstr "$GSH_HOME/Chateau/Labo" + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "Votre répertoire $repo n'est pas un dépot git." + +#, sh-format +msgid "The Glowing Finger spell scroll has already been registered into to your $spellbook repository!" +msgstr "Le parchemin du sortilège du Doigt Lumineux a déjà été enregistré dans votre dépot $spellbook !" diff --git a/missions/contrib/git_basics/02_create_file/i18n/template.pot b/missions/contrib/git_basics/02_create_file/i18n/template.pot new file mode 100644 index 000000000..2dad321b3 --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/i18n/template.pot @@ -0,0 +1,34 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +#, sh-format +msgid "$GSH_HOME/Castle/Library" +msgstr "" + +msgid "glowing_finger.spl" +msgstr "" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "" + +msgid "The Glowing Finger spell scroll isn't in your spellbook." +msgstr "" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab" +msgstr "" + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "" + +#, sh-format +msgid "The Glowing Finger spell scroll has already been registered into to your $spellbook repository!" +msgstr "" diff --git a/missions/contrib/git_basics/02_create_file/init.sh b/missions/contrib/git_basics/02_create_file/init.sh new file mode 100644 index 000000000..52ab2ecd0 --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/init.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + + +_mission_init() { + spell=$(gettext "glowing_finger.spl") + cp "$MISSION_DIR/glowing_finger.spl" "$(eval_gettext '$GSH_HOME/Castle/Library')/$spell" +} +_mission_init diff --git a/missions/contrib/git_basics/02_create_file/static.sh b/missions/contrib/git_basics/02_create_file/static.sh new file mode 100644 index 000000000..fa38ab27a --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/static.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +mkdir -p "$(eval_gettext "\$GSH_HOME/Castle/Lab")" +mkdir -p "$(eval_gettext "\$GSH_HOME/Castle/Library")" + diff --git a/missions/contrib/git_basics/02_create_file/test.sh b/missions/contrib/git_basics/02_create_file/test.sh new file mode 100644 index 000000000..349b0babd --- /dev/null +++ b/missions/contrib/git_basics/02_create_file/test.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +repo="$(eval_gettext '$GSH_HOME/Castle/Lab/Spellbook')" +library=$(eval_gettext '$GSH_HOME/Castle/Library') +spell=$(gettext "glowing_finger.spl") + +rm -f "$repo/$spell" +gsh assert check false + +cp "$library/$spell" "$repo" +( + cd "$repo" + git add "$(gettext "glowing_finger.spl")" >/dev/null 2>&1 +) +gsh assert check false + +( + cd "$repo" + git rm --cached "$(gettext "glowing_finger.spl")" >/dev/null 2>&1 +) +cp "$library/$spell" "$repo" +gsh assert check true + +unset spell repo diff --git a/missions/contrib/git_basics/03_add/Makefile b/missions/contrib/git_basics/03_add/Makefile new file mode 100644 index 000000000..2c0c50167 --- /dev/null +++ b/missions/contrib/git_basics/03_add/Makefile @@ -0,0 +1,41 @@ +SH_FILES=$(wildcard *.sh) +EXCEPTIONS= +OTHER_FILES= + +LANGUAGES=$(wildcard i18n/*.po) +LANGUAGES:=$(filter-out i18n/en.po, $(LANGUAGES)) +SH_FILES:=$(filter-out $(EXCEPTIONS), $(SH_FILES)) +SORT= +OPTIONS=--indent --no-wrap --no-location + +all: i18n/en.po $(LANGUAGES) + +add-locations: SORT=--add-location --sort-by-file +add-locations: all + +i18n/en.po: i18n/template.pot FORCE + @echo "msgen $@" + @msgen $(OPTIONS) $(SORT) i18n/template.pot --output=$@ + @echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" | cat - $@ > $@~ + @mv $@~ $@ + +$(LANGUAGES):%.po: i18n/template.pot FORCE + @echo "msgmerge $@" + @msgmerge --update $(OPTIONS) $(SORT) $@ i18n/template.pot + +i18n/template.pot: $(SH_FILES) $(OTHER_FILES) FORCE + @mkdir -p i18n/ + @echo "generating i18n/template.pot" + @xgettext --from-code=UTF-8 --omit-header $(OPTIONS) $(SORT) --join-existing --output i18n/template.pot $(SH_FILES) $(OTHER_FILES) + @echo "done" + +new: i18n/template.pot + @read -p "language code: " lang; \ + [ -e "./i18n/$$lang.po" ] && echo "file i18n/$$lang.po already exists" && exit; \ + echo "file i18n/$$lang.po created"; \ + msgcat $(OPTIONS) --output i18n/$$lang.po i18n/template.pot + +clean: + rm -f i18n/*~ + +.PHONY: all clean new FORCE diff --git a/missions/contrib/git_basics/03_add/auto.sh b/missions/contrib/git_basics/03_add/auto.sh new file mode 100644 index 000000000..9a4c43eff --- /dev/null +++ b/missions/contrib/git_basics/03_add/auto.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +( + spell=$(gettext "glowing_finger.spl") + repo="$(eval_gettext '$GSH_HOME/Castle/Lab/Spellbook')" + cd "$repo" + git add "$spell" +) +gsh check diff --git a/missions/contrib/git_basics/03_add/check.sh b/missions/contrib/git_basics/03_add/check.sh new file mode 100644 index 000000000..259b589a9 --- /dev/null +++ b/missions/contrib/git_basics/03_add/check.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +_mission_check() { + spell=$(gettext "glowing_finger.spl") + repo=$(eval_gettext '$GSH_HOME/Castle/Lab/Spellbook') + spellbook=$(basename "$repo") + + if ! git -C "$repo" rev-parse --is-inside-work-tree >/dev/null 2>&1 + then + echo "$(eval_gettext 'Your $spellbook directory is not a git repository.')" + return 1 + fi + + if [ ! -f "$repo/$spell" ] + then + echo "$(eval_gettext 'The Glowing Finger spell scroll is not in your $spellbook repository.')" + return 1 + fi + + # TODO: should we check for other files, staged or not and fail? + + if git -C "$repo" status --porcelain | grep "^A $spell" >/dev/null 2>&1 + then + # OK + return 0 + fi + + + if git -C "$repo" status --porcelain | grep "^?? $spell" >/dev/null 2>&1 + then + echo "$(eval_gettext "The Glowing Finger spell scroll hasn't been registered into your \$spellbook repository!")" + elif git -C "$repo" status --porcelain | grep "^AM $spell" >/dev/null 2>&1 + then + echo "$(gettext "The Glowing Finger spell scroll has been modified.")" + git -C "$repo" restore "$spell" >/dev/null 2>&1 + git -C "$repo" rm --cached "$spell" >/dev/null 2>&1 + fi + return 1 + +} +_mission_check diff --git a/missions/contrib/git_basics/03_add/goal/en.txt b/missions/contrib/git_basics/03_add/goal/en.txt new file mode 100644 index 000000000..6628a9948 --- /dev/null +++ b/missions/contrib/git_basics/03_add/goal/en.txt @@ -0,0 +1,25 @@ +Mission goal +============ + +So as you can see with `git status`, the spell that was added to the +`Spellbook` directory is not **tracked** by the portal system yet. + +Register the Glowing Finger spell file into the repository and check the +output of `git status`. + + +Useful commands +=============== + +git add FILENAME + Register a file into a git repository. + + +git status + Show the state of the working repository. + + +Remark +====== + +If you are already familiar with git, **do not 'commit'** the changes. diff --git a/missions/contrib/git_basics/03_add/goal/fr.txt b/missions/contrib/git_basics/03_add/goal/fr.txt new file mode 100644 index 000000000..0f62081fa --- /dev/null +++ b/missions/contrib/git_basics/03_add/goal/fr.txt @@ -0,0 +1,23 @@ +Objectif +======== + +blabla + + +Commandes utiles +================ + +git add FILENAME + Ajoute un fichier dans un dépot git. + (TODO: à améliorer) + + +git status + Affiche l'état du dépot courant. + + +Remark +====== + +Si vous êtes déjà familier avec git, **ne faites pas de 'commit'** des +modifications. diff --git a/missions/contrib/git_basics/03_add/i18n/en.po b/missions/contrib/git_basics/03_add/i18n/en.po new file mode 100644 index 000000000..a00173e45 --- /dev/null +++ b/missions/contrib/git_basics/03_add/i18n/en.po @@ -0,0 +1,38 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=ASCII\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "$MISSION_DIR/treasure-msg/en.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "$MISSION_DIR/skip/en.txt" + +msgid "glowing_finger.spl" +msgstr "glowing_finger.spl" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "$GSH_HOME/Castle/Lab/Spellbook" + +msgid "The Glowing Finger spell scroll has been modified." +msgstr "The Glowing Finger spell scroll has been modified." + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "Your $spellbook directory is not a git repository." + +#, sh-format +msgid "The Glowing Finger spell scroll is not in your $spellbook repository." +msgstr "The Glowing Finger spell scroll is not in your $spellbook repository." + +#, sh-format +msgid "The Glowing Finger spell scroll hasn't been registered into your $spellbook repository!" +msgstr "The Glowing Finger spell scroll hasn't been registered into your $spellbook repository!" diff --git a/missions/contrib/git_basics/03_add/i18n/fr.po b/missions/contrib/git_basics/03_add/i18n/fr.po new file mode 100644 index 000000000..81f343f2c --- /dev/null +++ b/missions/contrib/git_basics/03_add/i18n/fr.po @@ -0,0 +1,37 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/fr.txt" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +msgid "glowing_finger.spl" +msgstr "doigt_lumineux.srt" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "$GSH_HOME/Chateau/Labo/Grimoire" + +msgid "The Glowing Finger spell scroll has been modified." +msgstr "Le sortilège du Doigt Lumineux a été modifié." + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "Votre répertoire $spellbook n'est pas un dépot git." + +#, sh-format +msgid "The Glowing Finger spell scroll is not in your $spellbook repository." +msgstr "Le parchemin du sortilège du Doigt Lumineux n'est pas dans votre dépot $spellbook." + +#, sh-format +msgid "The Glowing Finger spell scroll hasn't been registered into your $spellbook repository!" +msgstr "Le parchemin du sortilège du Doigt Lumineux n'a pas été enregistré dans votre dépot Grimoire !" diff --git a/missions/contrib/git_basics/03_add/i18n/template.pot b/missions/contrib/git_basics/03_add/i18n/template.pot new file mode 100644 index 000000000..6e99346e0 --- /dev/null +++ b/missions/contrib/git_basics/03_add/i18n/template.pot @@ -0,0 +1,37 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +msgid "glowing_finger.spl" +msgstr "" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "" + +msgid "The Glowing Finger spell scroll has been modified." +msgstr "" + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "" + +#, sh-format +msgid "The Glowing Finger spell scroll is not in your $spellbook repository." +msgstr "" + +#, sh-format +msgid "The Glowing Finger spell scroll hasn't been registered into your $spellbook repository!" +msgstr "" diff --git a/missions/contrib/git_basics/04_commit/Makefile b/missions/contrib/git_basics/04_commit/Makefile new file mode 100644 index 000000000..2c0c50167 --- /dev/null +++ b/missions/contrib/git_basics/04_commit/Makefile @@ -0,0 +1,41 @@ +SH_FILES=$(wildcard *.sh) +EXCEPTIONS= +OTHER_FILES= + +LANGUAGES=$(wildcard i18n/*.po) +LANGUAGES:=$(filter-out i18n/en.po, $(LANGUAGES)) +SH_FILES:=$(filter-out $(EXCEPTIONS), $(SH_FILES)) +SORT= +OPTIONS=--indent --no-wrap --no-location + +all: i18n/en.po $(LANGUAGES) + +add-locations: SORT=--add-location --sort-by-file +add-locations: all + +i18n/en.po: i18n/template.pot FORCE + @echo "msgen $@" + @msgen $(OPTIONS) $(SORT) i18n/template.pot --output=$@ + @echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" | cat - $@ > $@~ + @mv $@~ $@ + +$(LANGUAGES):%.po: i18n/template.pot FORCE + @echo "msgmerge $@" + @msgmerge --update $(OPTIONS) $(SORT) $@ i18n/template.pot + +i18n/template.pot: $(SH_FILES) $(OTHER_FILES) FORCE + @mkdir -p i18n/ + @echo "generating i18n/template.pot" + @xgettext --from-code=UTF-8 --omit-header $(OPTIONS) $(SORT) --join-existing --output i18n/template.pot $(SH_FILES) $(OTHER_FILES) + @echo "done" + +new: i18n/template.pot + @read -p "language code: " lang; \ + [ -e "./i18n/$$lang.po" ] && echo "file i18n/$$lang.po already exists" && exit; \ + echo "file i18n/$$lang.po created"; \ + msgcat $(OPTIONS) --output i18n/$$lang.po i18n/template.pot + +clean: + rm -f i18n/*~ + +.PHONY: all clean new FORCE diff --git a/missions/contrib/git_basics/04_commit/auto.sh b/missions/contrib/git_basics/04_commit/auto.sh new file mode 100644 index 000000000..c3e5a907f --- /dev/null +++ b/missions/contrib/git_basics/04_commit/auto.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +( + repo="$(eval_gettext '$GSH_HOME/Castle/Lab/Spellbook')" + cd "$repo" + git add * + git commit -a -m "lorem ipsum" +) +git rev-parse HEAD | gsh check diff --git a/missions/contrib/git_basics/04_commit/check.sh b/missions/contrib/git_basics/04_commit/check.sh new file mode 100644 index 000000000..9096efb08 --- /dev/null +++ b/missions/contrib/git_basics/04_commit/check.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env sh + +_mission_check() { + spell=$(gettext "glowing_finger.spl") + repo=$(eval_gettext '$GSH_HOME/Castle/Lab/Spellbook') + spellbook=$(basename "$repo") + + if ! git -C "$repo" rev-parse --is-inside-work-tree >/dev/null 2>&1 + then + echo "$(eval_gettext 'Your $spellbook directory is not a git repository.')" + return 1 + fi + + if [ ! -f "$repo/$spell" ] + then + echo "$(eval_gettext 'The Glowing Finger spell scroll is not in your $spellbook repository.')" + return 1 + fi + + if [ "$(git -C "$repo" status --porcelain | wc -l)" -ne 0 ] + then + echo "$(eval_gettext 'Your $spellbook repository contains untracked files.')" + return 1 + elif ! git -C "$repo" diff --cached --quiet + then + echo "$(eval_gettext 'Your $spellbook repository contains unstaged changes.')" + return 1 + elif ! git -C "$repo" diff --cached --quiet + then + echo "$(eval_gettext 'Your $spellbook repository contains uncommited changes.')" + return 1 + fi + + # make sure the hash numbers are using lowercase hex digits (that should + # already be the case) + hash=$(git -C "$repo" rev-parse HEAD | tr 'A-F' 'a-f') + printf "%s " "$(gettext "What is your last commit's hash number?")" + read -r hash_answer + hash_answer=$(echo "$hash_answer" | tr 'A-F' 'a-f') + if [ ${#hash_answer} -lt 7 ] + then + echo "$(gettext "You must give at least 7 characters for a hash number.")" + return 1 + fi + if echo "$hash_answer" | grep -vq "^[0-9a-fA-F]*$" + then + echo "$(gettext "This hash number is invalid.")" + return 1 + fi + case "$hash" in + $hash_answer*) + return 0 + ;; + *) + if git -C "$repo" log --format="%H" | grep -q "^$hash_answer" + then + echo "$(gettext "This isn't the last commit's hash number.")" + else + echo "$(gettext "This isn't a valid hash number in your repository.")" + fi + return 1 + ;; + esac +} +_mission_check diff --git a/missions/contrib/git_basics/04_commit/goal/en.txt b/missions/contrib/git_basics/04_commit/goal/en.txt new file mode 100644 index 000000000..e6ee7e3e4 --- /dev/null +++ b/missions/contrib/git_basics/04_commit/goal/en.txt @@ -0,0 +1,19 @@ +Mission goal +============ + +The Glowing Finger spell is now registered into the Spellbook repository but +it hasn't been saved into the vault for long term storage. + +Save the current state of you Spellbook repository for long term storage and +check the logs to confirm this has been done. + + +Useful commands +=============== + +git commit -m 'COMMIT MESSAGE' + Create a snaphot of current repository. + The commit message should describe what has been done. + +git log + Show the list of all snapshots that have been recorded. diff --git a/missions/contrib/git_basics/04_commit/goal/fr.txt b/missions/contrib/git_basics/04_commit/goal/fr.txt new file mode 100644 index 000000000..6fa5275fa --- /dev/null +++ b/missions/contrib/git_basics/04_commit/goal/fr.txt @@ -0,0 +1,15 @@ +Objectif +======== + +blabla + + +Commandes utiles +================ + +git commit -m 'MESSAGE DE COMMIT' + Enregistre l'état du dépot courant. + Le message de commit doit décrire ce qui a été fait. + +git log + Affiche la liste des sauvegardes qui ont été faites. diff --git a/missions/contrib/git_basics/04_commit/i18n/en.po b/missions/contrib/git_basics/04_commit/i18n/en.po new file mode 100644 index 000000000..d83b32042 --- /dev/null +++ b/missions/contrib/git_basics/04_commit/i18n/en.po @@ -0,0 +1,58 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=ASCII\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "$MISSION_DIR/treasure-msg/en.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "$MISSION_DIR/skip/en.txt" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "$GSH_HOME/Castle/Lab/Spellbook" + +msgid "glowing_finger.spl" +msgstr "glowing_finger.spl" + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "Your $spellbook directory is not a git repository." + +#, sh-format +msgid "The Glowing Finger spell scroll is not in your $spellbook repository." +msgstr "The Glowing Finger spell scroll is not in your $spellbook repository." + +#, sh-format +msgid "Your $spellbook repository contains untracked files." +msgstr "Your $spellbook repository contains untracked files." + +#, sh-format +msgid "Your $spellbook repository contains unstaged changes." +msgstr "Your $spellbook repository contains unstaged changes." + +#, sh-format +msgid "Your $spellbook repository contains uncommited changes." +msgstr "Your $spellbook repository contains uncommited changes." + +msgid "What is your last commit's hash number?" +msgstr "What is your last commit's hash number?" + +msgid "You must give at least 7 characters for a hash number." +msgstr "You must give at least 7 characters for a hash number." + +msgid "This hash number is invalid." +msgstr "This hash number is invalid." + +msgid "This isn't the last commit's hash number." +msgstr "This isn't the last commit's hash number." + +msgid "This isn't a valid hash number in your repository." +msgstr "This isn't a valid hash number in your repository." diff --git a/missions/contrib/git_basics/04_commit/i18n/fr.po b/missions/contrib/git_basics/04_commit/i18n/fr.po new file mode 100644 index 000000000..b211134bd --- /dev/null +++ b/missions/contrib/git_basics/04_commit/i18n/fr.po @@ -0,0 +1,56 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/fr.txt" + +# path for the text file containing the goal +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "$GSH_HOME/Chateau/Labo/Grimoire" + +msgid "glowing_finger.spl" +msgstr "doigt_lumineux.srt" + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "Votre répertoire $spellbook n'est pas un dépot git." + +#, sh-format +msgid "The Glowing Finger spell scroll is not in your $spellbook repository." +msgstr "Le parchemin du sortilège du Doigt Lumineux n'est pas dans votre grimoire." + +#, sh-format +msgid "Your $spellbook repository contains untracked files." +msgstr "Votre dépot $spellbook contient des fichiers non suivis." + +#, sh-format +msgid "Your $spellbook repository contains unstaged changes." +msgstr "Votre dépot $spellbook contient des modifications non planifiées." + +#, sh-format +msgid "Your $spellbook repository contains uncommited changes." +msgstr "Votre dépot $spellbook contient des modifications non enregistrées." + +msgid "What is your last commit's hash number?" +msgstr "Quel est l'empreinte du dernier commit ?" + +msgid "You must give at least 7 characters for a hash number." +msgstr "Vous devez donner au moins 7 caractères pour une empreinte." + +msgid "This hash number is invalid." +msgstr "Cette empreinte est invalide." + +msgid "This isn't the last commit's hash number." +msgstr "Ce n'est pas l'empreinte du dernier commit." + +msgid "This isn't a valid hash number in your repository." +msgstr "Ce n'est pas une empreinte valide dans votre dépot." diff --git a/missions/contrib/git_basics/04_commit/i18n/template.pot b/missions/contrib/git_basics/04_commit/i18n/template.pot new file mode 100644 index 000000000..73b1f2b86 --- /dev/null +++ b/missions/contrib/git_basics/04_commit/i18n/template.pot @@ -0,0 +1,57 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +#, sh-format +msgid "$GSH_HOME/Castle/Lab/Spellbook" +msgstr "" + +msgid "glowing_finger.spl" +msgstr "" + +#, sh-format +msgid "Your $spellbook directory is not a git repository." +msgstr "" + +#, sh-format +msgid "The Glowing Finger spell scroll is not in your $spellbook repository." +msgstr "" + +#, sh-format +msgid "Your $spellbook repository contains untracked files." +msgstr "" + +#, sh-format +msgid "Your $spellbook repository contains unstaged changes." +msgstr "" + +#, sh-format +msgid "Your $spellbook repository contains uncommited changes." +msgstr "" + +msgid "What is your last commit's hash number?" +msgstr "" + +msgid "You must give at least 7 characters for a hash number." +msgstr "" + +msgid "This hash number is invalid." +msgstr "" + +msgid "This isn't the last commit's hash number." +msgstr "" + +msgid "This isn't a valid hash number in your repository." +msgstr "" diff --git a/missions/contrib/git_basics/TODO.md b/missions/contrib/git_basics/TODO.md new file mode 100644 index 000000000..a74d899af --- /dev/null +++ b/missions/contrib/git_basics/TODO.md @@ -0,0 +1,20 @@ + - [x] `git config user.name` (00_config, old name 02_configGitID) + - [x] `git init` a new repo (01_init, new) + - [ ] cloning a repo => requires clarifying how to deal with remotes + - [x] creating a file that is not yet added (02_create_file, old name 02a_...) + - [x] adding a new file (03_add, old name 02b_...) + - [x] commiting a new file (04_commit, old name 02c_...) + - [ ] adding changes to a tracked file (new) + - [ ] `git diff` and possibly variants `git diff --staged` and `git diff HEAD` (new) + - [ ] .gitignore file + - [ ] `git checkout OLD_HASH` (old name 05[ab]_...) + + +The next missions could be moved to git_misc? + + - [ ] `git mv` (old name 02_git_mv) => should there be something about `mv +SOURCE DEST FILE ; git add SOURCE`? + - [ ] `git rm` (old name 04_git_rm) => should there be something about `rm +FILE; git add FILE`, possibly in another mission? + + diff --git a/missions/contrib/git_branches/TODO.md b/missions/contrib/git_branches/TODO.md new file mode 100644 index 000000000..3cb32ca57 --- /dev/null +++ b/missions/contrib/git_branches/TODO.md @@ -0,0 +1,13 @@ +The order of the following missions is not yet clear + + - [ ] `git switch -c` to create a new local branch + - [ ] `git switch ...` in order to get a distant branch => check it works with local remotes + - [ ] `git branch` + - [ ] several missions about merging, conflicts, etc. to be refined from existing missions in gameshell_git + - [ ] ??? mission(s) about `git rebase` and associated problems ??? + + +The following could go in git_remotes + + - [ ] `git branch -r` to get list of branches + - [ ] `git branch -vv` to see associated commits and remotes diff --git a/missions/contrib/git_misc/TODO.md b/missions/contrib/git_misc/TODO.md new file mode 100644 index 000000000..075e6f8bf --- /dev/null +++ b/missions/contrib/git_misc/TODO.md @@ -0,0 +1,6 @@ + - [ ] couple of missions about `git stash` and related + - [ ] ??? `git restore` ??? => probably a good idea + - [ ] ??? `git reset` ??? + - [ ] ??? `git revert` ??? + - [ ] `git branch -d`, possibly `git branch -m` ??? + - [ ] `git checkout; git branch` to work on a old version of the repo diff --git a/missions/contrib/git_remotes/TODO.md b/missions/contrib/git_remotes/TODO.md new file mode 100644 index 000000000..c7c9d2f92 --- /dev/null +++ b/missions/contrib/git_remotes/TODO.md @@ -0,0 +1,20 @@ + + - [ ] clarify and experiments with local remotes (see below) + - [ ] `git clone` + - [ ] `git push` + - [ ] `git pull` and / or `git fetch` + - [ ] ??? `git remote show` ??? + - [ ] ??? adding / removing remotes ??? (in most cases, the remotes is configured automatically when using a remote branch...) + + +Local remotes could be used instead of remote gitlab / github repositories. + + - We could use a bare repository inside Gameshell that is cloned in a + strange path, where the parent directory without rwx permissions. (players + cannot really "go there" + - Those repo apparently don't need the r permission but require the x + permission (otherwise, cloning is not possible). + - If we don't want player to push there, they don't need the w permission. + +We could define an environment variable so that cloning such a repo doesn't +"feel" like cloning a local directory. (Not sure this is worth it...)