diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1e559fe --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,39 @@ +# Use SUSE BCI Golang as the base image +FROM registry.suse.com/bci/golang:1.25 + +# Install VCS tools and other dependencies +RUN zypper --non-interactive refresh && \ + zypper --non-interactive install -y \ + git \ + mercurial \ + subversion \ + bzr \ + make \ + curl \ + sudo \ + shadow && \ + zypper clean --all + +# Create a non-root user for development +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +RUN groupadd --gid $USER_GID $USERNAME && \ + useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \ + echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \ + chmod 0440 /etc/sudoers.d/$USERNAME + +# Set up Go workspace +ENV GOPATH=/go +ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH + +# Create Go workspace directories with correct permissions +RUN mkdir -p /go/src /go/bin /go/pkg && \ + chown -R $USERNAME:$USERNAME /go + +# Switch to the non-root user +USER $USERNAME + +# Set working directory +WORKDIR /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..681c35b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +{ + "name": "VCS Development Container", + "build": { + "dockerfile": "Dockerfile" + }, + "customizations": { + "vscode": { + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true + }, + "extensions": [ + "golang.go" + ] + } + }, + "postCreateCommand": "go mod download", + "remoteUser": "vscode" +} diff --git a/README.md b/README.md index 0e41199..36d10f2 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ interface. Quick usage: remote := "https://github.com/Masterminds/vcs" - local, _ := ioutil.TempDir("", "go-vcs") + local, _ := os.TempDir("", "go-vcs") repo, err := NewRepo(remote, local) In this case `NewRepo` will detect the VCS is Git and return a `GitRepo`. All of @@ -39,6 +39,25 @@ The constructors have the same signature as `NewRepo`. For more details see [the documentation](https://godoc.org/github.com/Masterminds/vcs). +## Development + +### Using Dev Container + +This project includes a [development container](https://containers.dev/) configuration that provides a complete development environment with all required version control tools (Git, Mercurial, Subversion, and Bazaar) pre-installed. + +To use the dev container: + +1. Install [Docker](https://www.docker.com/products/docker-desktop) and [Visual Studio Code](https://code.visualstudio.com/) +2. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for VS Code +3. Open this repository in VS Code +4. When prompted, click "Reopen in Container" (or use the command palette: "Dev Containers: Reopen in Container") + +The dev container is based on the SUSE BCI Golang image and includes: +- Go development environment +- Git, Mercurial (hg), Subversion (svn), and Bazaar (bzr) +- Go language server and tools +- All dependencies needed to run tests + ## Motivation The package `golang.org/x/tools/go/vcs` provides some valuable functionality