-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcommitjb
executable file
·47 lines (38 loc) · 1.64 KB
/
commitjb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -eu
DOTFILES_DIR="${HOME}/.dotfiles"
DOTFILES_WORKSPACE_REPO_DIR="${DOTFILES_DIR}/workspace_repo"
DOTFILES_HOME_DIR="${DOTFILES_DIR}/home_files"
DOTFILES_EPHEMERAL_JB_DIR="${DOTFILES_DIR}/ephemeral_jetbrains_config"
PERSISTENT_JB_DIR="${HOME}/.gitpod/jetbrains/${JETBRAINS_GITPOD_BACKEND_KIND:-}"
PERSISTENT_DOTFILES_DIR="${DOTFILES_HOME_DIR}/${PERSISTENT_JB_DIR#$HOME/}"
EPHEMERAL_JB_DIR=(/workspace/.config/JetBrains/RemoteDev-*)
EPHEMERAL_JB_OPTIONS_DIR="${EPHEMERAL_JB_DIR}/options"
function cpar() { command cp -ar "$@" 2>/dev/null || :; }
(
mkdir -p "${PERSISTENT_DOTFILES_DIR}"
cpar "${EPHEMERAL_JB_OPTIONS_DIR}" "${PERSISTENT_DOTFILES_DIR}"
# home/.config dir
if test -e "${HOME}/.config/JetBrains"; then
mkdir -p "${DOTFILES_HOME_DIR}/.config"
cpar "${HOME}/.config/JetBrains" "${DOTFILES_HOME_DIR}/.config"
fi
# .idea/workspace.xml for persisting IDE UI layout and etc.
workspace_xml="${GITPOD_REPO_ROOT}/.idea/workspace.xml"
if test -e "${workspace_xml}"; then
mkdir -p "${DOTFILES_WORKSPACE_REPO_DIR}/.idea"
cpar "${workspace_xml}" "${DOTFILES_WORKSPACE_REPO_DIR}/.idea"
fi
# /workspace/.config/JetBrains/RemoteDev-*/templates
templates_dir="${EPHEMERAL_JB_DIR}/templates"
if test -e "${templates_dir}"; then
mkdir -p "${DOTFILES_EPHEMERAL_JB_DIR}"
cpar "${templates_dir}" "${DOTFILES_EPHEMERAL_JB_DIR}/"
fi
"$HOME/.dotfiles/install.sh"
cd "${DOTFILES_DIR}"
git add .
git commit -m 'Automatic commit for updating Jetbrains config'
git push
)
printf '[info] %s\n' "Successfully cloned JB files to a persistent location"