Skip to content

Commit 502aa27

Browse files
authored
Merge pull request commercialhaskell#6759 from benz0li/update-dev-containers-65c6dc0
Dev Containers: Add initializeCommand
2 parents 65c6dc0 + 43cbeec commit 502aa27

File tree

7 files changed

+44
-0
lines changed

7 files changed

+44
-0
lines changed

.devcontainer/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
!/devcontainer.json
2929
!/GHC.Dockerfile
30+
!/init
31+
!/init.cmd
3032
!/LICENSE
3133
!/README.md
3234

.devcontainer/LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ https://github.com/devcontainers/features/blob/main/LICENSE for
3333
license information.
3434

3535
--------------------------------------------------------------------------------
36+
.devcontainer/init
37+
Copyright (c) 2025 b-data GmbH
38+
Copyright (c) 2023 Microsoft Corporation
39+
40+
Distributed under the terms of the MIT License.
41+
42+
--------------------------------------------------------------------------------

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
}
1313
},
1414

15+
"initializeCommand": [".devcontainer/init"],
1516
"onCreateCommand": "onCreateCommand.sh",
1617
"postCreateCommand": "postCreateCommand.sh",
1718

.devcontainer/ghc-9.10.2/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
}
1313
},
1414

15+
"initializeCommand": [".devcontainer/init"],
1516
"onCreateCommand": "onCreateCommand.sh",
1617
"postCreateCommand": "postCreateCommand.sh",
1718

.devcontainer/ghc-9.12.2/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
}
1313
},
1414

15+
"initializeCommand": [".devcontainer/init"],
1516
"onCreateCommand": "onCreateCommand.sh",
1617
"postCreateCommand": "postCreateCommand.sh",
1718

.devcontainer/init

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2025 b-data GmbH
3+
# Copyright (c) 2023 Microsoft Corporation
4+
# Distributed under the terms of the MIT License.
5+
#
6+
# https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials
7+
# https://docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases?platform=windows
8+
#
9+
# Modified by b-data for seamless use with development containers.
10+
11+
set -e
12+
13+
if [ -z "$CODESPACES" ] && [ "$(command -v ssh-agent)" ]; then
14+
if [ -z "$SSH_AUTH_SOCK" ]; then
15+
# Check for a currently running instance of the agent
16+
RUNNING_AGENT="$(pgrep -f 'ssh-agent -s' | wc -l | tr -d '[:space:]')"
17+
if [ "$RUNNING_AGENT" = "0" ] || [ ! -f "$HOME/.ssh/ssh-agent" ]; then
18+
mkdir -p -m 0700 "$HOME/.ssh"
19+
# Launch a new instance of the agent
20+
ssh-agent -s &> "$HOME/.ssh/ssh-agent"
21+
fi
22+
eval "$(cat "$HOME/.ssh/ssh-agent")" > /dev/null
23+
fi
24+
# Check the state of the currently running instance of the agent
25+
# 0: running with key(s); 1: running w/o key(s); 2: not running
26+
AGENT_RUN_STATE="$(ssh-add -l > /dev/null 2>&1; echo $?)"
27+
# Only add key(s) if running w/o key(s)
28+
if [ "$AGENT_RUN_STATE" = "1" ]; then
29+
ssh-add 2> /dev/null || true
30+
fi
31+
# Means: Not adding key(s) to a forwarded agent with key(s)
32+
fi

.devcontainer/init.cmd

Whitespace-only changes.

0 commit comments

Comments
 (0)