Skip to content

Commit

Permalink
Tutorial CI/CD tweaks
Browse files Browse the repository at this point in the history
 - do not crash on tag that have been checked out in grafted mode
   (without a branch name)
  • Loading branch information
DrYak committed Nov 2, 2022
1 parent 1df85e9 commit 72452b3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docs/convert.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/usr/bin/env bash

# branch (for usual PR and pushes)
branch="$(git branch --show-current)"
# fall back on tags if branch was left empty (checked out in grafted/detached head mode, e.g. when testing a tag)
branch="${branch:-$(git describe --tags)}"
# fall back to hash
branch="${branch:-$(git rev-parse HEAD)}"

default="master"
echo "current branch: ${branch}"

if [[ "${1}" == "branch" ]]; then
if [[ "${branch}" != "${default}" ]]; then
if [[ -z "${branch}" ]]; then
echo -e "\e[31;1mCannot determine current branch or tag!\e[0m The installer in tutorials will still clone the \`${default}\` branch."
elif [[ "${branch}" != "${default}" ]]; then
echo "patching tutorials..."
sed -ri "s@(quick_install.sh) +(-[^b])@\1 -b ${branch} \2@g;s@(V-pipe)/${default}(/utils)@\1/${branch}\2@g" ./*.md
sed -ri "s@(quick_install.sh) +(-[^b])@\1 -b ${branch} \2@g;s@(V-pipe)/${default}(/utils)@\1/${branch}\2@g" ./tutorial*.md
## example command to keep the output with errors
# jupytext --to ipynb --pipe-fmt ipynb --pipe 'jupyter nbconvert --to ipynb --execute --allow-errors --stdin --stdout' ./*.md
else
Expand Down

0 comments on commit 72452b3

Please sign in to comment.