set meaningful defaults for git in post-create - #2
Open
marc-hanheide wants to merge 1 commit into
Open
marc-hanheide wants to merge 1 commit into
marc-hanheide wants to merge 1 commit into
Conversation
Author
|
@cooperj, could you possibly test this on Windows to see if it works in principle? Just want to make sure I don't destroy anyone's experience. |
Member
|
Tested on a lab pc, and it has reported back an error. [15143 ms] postStartCommand failed with exit code 127. Skipping any further user-provided commands.
[15146 ms] Error: Command failed: /bin/sh -c /opt/entrypoint.sh /bin/true; .devcontainer/post-create.sh
[15146 ms] at G7 (c:\Users\Student\.vscode\extensions\ms-vscode-remote.remote-containers-0.394.0\dist\spec-node\devContainersSpecCLI.js:235:130)
[15147 ms] at async tm (c:\Users\Student\.vscode\extensions\ms-vscode-remote.remote-containers-0.394.0\dist\spec-node\devContainersSpecCLI.js:227:4483)
[15147 ms] at async b7 (c:\Users\Student\.vscode\extensions\ms-vscode-remote.remote-containers-0.394.0\dist\spec-node\devContainersSpecCLI.js:227:4000)
[15147 ms] at async em (c:\Users\Student\.vscode\extensions\ms-vscode-remote.remote-containers-0.394.0\dist\spec-node\devContainersSpecCLI.js:227:3192)
[15147 ms] at async GrA (c:\Users\Student\.vscode\extensions\ms-vscode-remote.remote-containers-0.394.0\dist\spec-node\devContainersSpecCLI.js:666:2752)
[15147 ms] at async LrA (c:\Users\Student\.vscode\extensions\ms-vscode-remote.remote-containers-0.394.0\dist\spec-node\devContainersSpecCLI.js:665:8554)
[15147 ms] at async c:\Users\Student\.vscode\extensions\ms-vscode-remote.remote-containers-0.394.0\dist\spec-node\devContainersSpecCLI.js:482:1190
[15179 ms] Exit code 1
[15179 ms] Command failed: C:\Users\Student\AppData\Local\Programs\Microsoft VS Code\Code.exe c:\Users\Student\.vscode\extensions\ms-vscode-remote.remote-containers-0.394.0\dist\spec-node\devContainersSpecCLI.js run-user-commands --user-data-folder c:\Users\Student\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-containers\data --container-session-data-folder /tmp/devcontainers-b1894210-d687-431f-a99e-953fd0badebb1738162661034 --workspace-folder c:\Users\Student\Desktop\cmp3103-ws --id-label devcontainer.local_folder=c:\Users\Student\Desktop\cmp3103-ws --id-label devcontainer.config_file=c:\Users\Student\Desktop\cmp3103-ws\.devcontainer\devcontainer.json --container-id 4e26ef79182e9d3e8b47fa9d60e251c9657850b1bbf6c2427dec0f99ccc334ce --log-level debug --log-format json --config c:\Users\Student\Desktop\cmp3103-ws\.devcontainer\devcontainer.json --default-user-env-probe loginInteractiveShell --skip-non-blocking-commands false --prebuild false --stop-for-personalization false --remote-env REMOTE_CONTAINERS_IPC=/tmp/vscode-remote-containers-ipc-67b93423-88e7-46a2-9a62-ccc2082b490c.sock --remote-env REMOTE_CONTAINERS=true --mount-workspace-git-root --terminal-columns 217 --terminal-rows 35 --dotfiles-target-path ~/dotfilesAnd then when running the script with ros@4e26ef79182e:/workspaces/cmp3103-ws/.devcontainer$ bash post-create.sh
post-create.sh: line 2: $'\r': command not found
: invalid optionline 3: set: -
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
post-create.sh: line 4: $'\r': command not found
post-create.sh: line 5: $'\r': command not found
post-create.sh: line 6: syntax error near unexpected token `$'{\r''
'ost-create.sh: line 6: `function add_config_if_not_exist { |
Author
|
bloody line endings... can you try fixing them (redo the line endings on windows) and commit? them I'll try again on my end, @cooperj ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new function to the
.devcontainer/post-create.shscript for setting global Git configuration options if they do not already exist. Additionally, it includes several calls to this new function to set specific Git configurations.This is to overcome some user challenges, where git cannot commit because a
user.nameanduser.emailis not set in~/.gitconfig. VSCode copies these settings from the host, if they are configured there, or the user has properly set up VSCode already, then it is also correctly set in the container. However, if they don't set it (newbie user), then this sets them to defaults that work.It also configures the container user's git to handle the CRLF/ LF issue of compatibility between Linux and Windows. This should work, but I don't have Windows to test it.
Enhancements to
.devcontainer/post-create.sh:add_git_config_if_not_existfunction to check and set global Git configuration options if they are not already set.add_git_config_if_not_existfunction:core.autocrlfset toinputcore.safecrlfset towarnpull.rebaseset tofalseuser.nameset toAnonymous L-CAS DevContainer Useruser.emailset tonoreply@lcas.lincoln.ac.ukinit.defaultBranchset tomain