Commit 1d51485a authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'feature/multi-build' into 'main'

feat: multi-projects build support

See merge request to-be-continuous/dotnet!13
parents 3ca65af9 1814449c
Loading
Loading
Loading
Loading

.devcontainer/.profile

0 → 100644
+80 −0
Original line number Diff line number Diff line
C_RESET=$(printf '\033[0m')
C_WHITE=$(printf '\033[0;37m')
C_GREEN=$(printf '\033[0;32m')
C_BLUE_BOLD=$(printf '\033[1;34m')
C_CYAN_BOLD=$(printf '\033[1;36m')
C_RED_BOLD=$(printf '\033[1;31m')
C_YELLOW_BOLD=$(printf '\033[1;33m')

# --- 2. Helper function to truncate the working directory ---
# Recreates ZSH's `%-1~/…/%3~` style truncation for long paths.
prompt_pwd() {
    # Replace the home directory with a tilde '~'
    local path
    path=$(echo "$PWD" | sed "s|^$HOME|~|")

    # If the path has more than 4 slashes, truncate it. Otherwise, print it as is.
    echo "$path" | awk -F/ '
        {
            if (NF > 5) {
                printf "%s/…/%s/%s/%s", $1, $(NF-2), $(NF-1), $NF
            } else {
                print $0
            }
        }
    '
}

# --- 3. Helper function to get Git branch and dirty status ---
# This contains the logic for displaying Git information.
prompt_git() {
    # Check if git status should be hidden (a feature from the original prompt)
    if [ "$(git config --get devcontainers-theme.hide-status 2>/dev/null)" = 1 ] || \
       [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" = 1 ]; then
        return
    fi

    # Get the current branch name or commit hash
    local BRANCH
    BRANCH=$(git --no-optional-locks symbolic-ref --short HEAD 2>/dev/null || git --no-optional-locks rev-parse --short HEAD 2>/dev/null)

    if [ -n "${BRANCH}" ]; then
        # Start printing the git part: (branch
        printf "%s(%s%s" "${C_CYAN_BOLD}" "${C_RED_BOLD}" "${BRANCH}"

        # Check if the repo is dirty and display a '✗' if needed
        if [ "$(git config --get devcontainers-theme.show-dirty 2>/dev/null)" = 1 ] && \
           git --no-optional-locks ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then
            printf " %s✗" "${C_YELLOW_BOLD}"
        fi
        
        # Close the git part: )
        printf "%s) " "${C_CYAN_BOLD}"
    fi
}

# --- 4. Main function to build the prompt string ---
# This function is called every time the prompt is displayed.
build_prompt() {
    local exit_code=$? # Capture the exit code of the last command *immediately*

    # Part 1: User and status arrow
    # User is always green. Arrow is red on failure, reset (default) on success.
    printf "%s%s " "$C_GREEN" "$USER"
    if [ "$exit_code" -ne 0 ]; then
        printf "%s➜ " "${C_RED_BOLD}"
    else
        printf "%s➜ " "${C_RESET}"
    fi

    # Part 2: Current Directory (truncated)
    printf "%s%s%s " "${C_BLUE_BOLD}" "$(prompt_pwd)" "${C_RESET}"

    # Part 3: Git Status
    printf "%s" "$(prompt_git)"

    # Part 4: Final prompt symbol
    printf "%s\$ %s" "${C_WHITE}" "${C_RESET}"
}

export PS1="\$(build_prompt)"
 No newline at end of file
+35 −0
Original line number Diff line number Diff line
{
    "name": "TBC: .NET Pipeline Environment",
    "image": "mcr.microsoft.com/devcontainers/base:alpine",
    "features": {
        "ghcr.io/edouard-lopez/devcontainer-features/bats:0": {}
    },
    "customizations": {
        "vscode": {
            "extensions": [
                "mads-hartmann.bash-ide-vscode",
                "foxundermoon.shell-format",
                "jetmartin.bats",
                "GitLab.gitlab-workflow"
            ],
            "settings": {
                "terminal.integrated.defaultProfile.linux": "ash",
                "terminal.integrated.profiles.linux": {
                    "ash": {
                        "path": "ash",
                        "icon": "terminal-bash"
                    }
                }
            }
        }
    },
    "mounts": [
        "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached",
        "source=${localWorkspaceFolder}/.devcontainer/.profile,target=/home/vscode/.profile,type=bind,consistency=cached"
    ],
    "postStartCommand": "sudo apk add --update shellcheck bats ruby dash xq xmlstarlet && sudo gem install simplecov bashcov",
    "remoteEnv": {
        "ENV": "/home/vscode/.profile",
        "BATS_LIBRARIES_DIR": "/usr/lib/bats"
    }
}
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -21,3 +21,8 @@
/nbdist/
/.nb-gradle/
.DS_Store
coverage/
src/
tmp/
*.tar.gz
*.zip
+4 −0
Original line number Diff line number Diff line
@@ -11,6 +11,10 @@ include:
  - component: $CI_SERVER_FQDN/to-be-continuous/bash/gitlab-ci-bash@3
    inputs:
      shellcheck-files: "*.sh"
      bats-enabled: true
      bats-libraries: "bats-support@https://github.com/bats-core/bats-support/archive/v0.3.0.zip bats-assert@https://github.com/bats-core/bats-assert/archive/v2.1.0.zip bats-file@https://github.com/bats-core/bats-file/archive/v0.4.0.zip"
      coverage-enabled: true
      bats-opts: "-t --verbose-run"
  - component: $CI_SERVER_FQDN/to-be-continuous/semantic-release/gitlab-ci-semrel@4
    inputs:
      # disable semrel for all synch'd repositories
+298 −26

File changed.

Preview size limit exceeded, changes collapsed.

Loading