Skip to content

Commit 88253ef

Browse files
common-utils zshrc issue fix (#1111)
* common-utils zshrc issue fix * bump feature patch version * test added to validate the changes of zshrc fix * user vscode added * User env added
1 parent d231662 commit 88253ef

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

src/common-utils/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "common-utils",
3-
"version": "2.5.1",
3+
"version": "2.5.2",
44
"name": "Common Utilities",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
66
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",

src/common-utils/main.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,9 @@ if [ "${INSTALL_ZSH}" = "true" ]; then
551551

552552
# Add devcontainer .zshrc template
553553
if [ "$INSTALL_OH_MY_ZSH_CONFIG" = "true" ]; then
554-
echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
554+
if ! [ -f "${template_path}" ] || ! grep -qF "$(head -n 1 "${template_path}")" "${user_rc_file}"; then
555+
echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
556+
fi
555557
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="devcontainers"/g' ${user_rc_file}
556558
fi
557559

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# Definition specific tests
9+
check "configure-zshrc-without-overwrite" bash -c "grep 'rbenv init -' ~/.zshrc"
10+
11+
# Report result
12+
reportResults
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM mcr.microsoft.com/devcontainers/ruby:3.2
2+
3+
USER vscode
4+
ENV USER=vscode
5+
RUN echo 'eval "$(rbenv init -)"' >> /home/$USER/.zshrc
6+

test/common-utils/scenarios.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,24 @@
235235
}
236236
}
237237
},
238+
"devcontainer-ruby-zshrc": {
239+
"build": {
240+
"dockerfile": "Dockerfile"
241+
},
242+
"remoteUser": "vscode",
243+
"features": {
244+
"common-utils": {
245+
"installZsh": true,
246+
"username": "vscode",
247+
"userUid": "1000",
248+
"userGid": "1000",
249+
"upgradePackages": true,
250+
"installOhMyZsh": true,
251+
"installOhMyZshConfig": true,
252+
"configureZshAsDefaultShell": true
253+
}
254+
}
255+
},
238256
"alpine-base-zsh-default": {
239257
"image": "mcr.microsoft.com/devcontainers/base:alpine",
240258
"remoteUser": "vscode",

0 commit comments

Comments
 (0)