Skip to content

Commit

Permalink
common-utils zshrc issue fix (#1111)
Browse files Browse the repository at this point in the history
* common-utils zshrc issue fix

* bump feature patch version

* test added to validate the changes of zshrc fix

* user vscode added

* User env added
  • Loading branch information
prathameshzarkar9 authored Oct 17, 2024
1 parent d231662 commit 88253ef
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/common-utils/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "common-utils",
"version": "2.5.1",
"version": "2.5.2",
"name": "Common Utilities",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",
Expand Down
4 changes: 3 additions & 1 deletion src/common-utils/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ if [ "${INSTALL_ZSH}" = "true" ]; then

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

Expand Down
12 changes: 12 additions & 0 deletions test/common-utils/devcontainer-ruby-zshrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

# Definition specific tests
check "configure-zshrc-without-overwrite" bash -c "grep 'rbenv init -' ~/.zshrc"

# Report result
reportResults
6 changes: 6 additions & 0 deletions test/common-utils/devcontainer-ruby-zshrc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mcr.microsoft.com/devcontainers/ruby:3.2

USER vscode
ENV USER=vscode
RUN echo 'eval "$(rbenv init -)"' >> /home/$USER/.zshrc

18 changes: 18 additions & 0 deletions test/common-utils/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,24 @@
}
}
},
"devcontainer-ruby-zshrc": {
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "vscode",
"features": {
"common-utils": {
"installZsh": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"configureZshAsDefaultShell": true
}
}
},
"alpine-base-zsh-default": {
"image": "mcr.microsoft.com/devcontainers/base:alpine",
"remoteUser": "vscode",
Expand Down

0 comments on commit 88253ef

Please sign in to comment.