Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chart): revert the removal of autosave bash script #1011

Merged
merged 1 commit into from
Apr 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions helm-chart/renku-notebooks/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,47 @@ data:
{{ .Values.serverOptions | default dict | toJson }}
server_defaults.json: |
{{ toJson .Values.serverDefaults }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: notebook-helper-scripts
labels:
app: {{ template "notebooks.name" . }}
chart: {{ template "notebooks.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
pre-stop.sh: |
#!/bin/bash
UNCOMMITTED_CHANGES=`git status -s`
UNPUSHED_COMMITS=`git log --branches --not --remotes`
if [ "${GIT_AUTOSAVE}" != "1" ] ; then
exit 0
fi
if [ -z "$UNCOMMITTED_CHANGES" ] && [ -z "$UNPUSHED_COMMITS" ]; then
exit 0
fi
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
LOCAL_SHA=`git rev-parse --short HEAD`
INITIAL_SHA="${CI_COMMIT_SHA:0:7}"
AUTOSAVE_BRANCH="renku/autosave/$RENKU_USERNAME/${CURRENT_BRANCH}/${INITIAL_SHA}/${LOCAL_SHA}"
if [ -z "$UNCOMMITTED_CHANGES" ] && [ ! -z "$UNPUSHED_COMMITS" ]; then
# there are only unpushed commits
git checkout -b "$AUTOSAVE_BRANCH"
git push origin "$AUTOSAVE_BRANCH"
git checkout "$CURRENT_BRANCH"
git branch -D "$AUTOSAVE_BRANCH"
fi
if [ ! -z "$UNCOMMITTED_CHANGES" ]; then
# there are uncommitted changes
git stash --include-untracked
git checkout -b "$AUTOSAVE_BRANCH"
git stash apply
git add .
git commit -am "Auto-saving for $RENKU_USERNAME on branch $CURRENT_BRANCH from commit $INITIAL_SHA"
git push origin "$AUTOSAVE_BRANCH"
git checkout "$CURRENT_BRANCH"
git branch -D "$AUTOSAVE_BRANCH"
git stash pop
fi