Browse Source

Cleanup and lint start_docker.sh script

my-config
connorgmeean 3 years ago
committed by Alejandro
parent
commit
eb9e877ec8
  1. 6
      contribute/README.md
  2. 73
      contribute/start_docker.sh
  3. 12
      docs/contributing.md

6
contribute/README.md

@ -1,6 +1,6 @@
# Contributing Tools for Doom Neovim
This directory stores various tools has
This directory stores various tools and automations to help contributors or develpers of doom-nvim.
## Doom Contrib Docker Image `./start_docker.sh`
@ -13,7 +13,7 @@ The setup and start process is handled in the `./start_docker.sh` script.
```
Bootstraps a docker image for contributing changes to doom-nvim
Syntax: ./start_docker.sh [-b <branc_name>]
Syntax: ./start_docker.sh [-b <branch_name>]
options:
-b Create a new branch for the contribution (default is doom-nvim-contrib)
-h Shows this help menu
@ -22,7 +22,7 @@ options:
### What this script does
1. On first execution it will setup a git worktree of doom-nvim, this means your main config and this copy of the repo will share the same git history.
- This worktree will be placed in the `docker/doom-nvim-contrib` folder inside of this repository.
- This worktree will be placed in the `contribute/doom-nvim-contrib` folder inside of this repository.
- Because they share history you wont be able to checkout the same branch on both copies of the repository. Unless specified, a new branch called `doom-nvim-contrib` will be created off the latest version of `develop`.
2. It will setup a new docker image to run this config within (if necessary).
3. It will then start the docker image and enter you into neovim.

73
contribute/start_docker.sh

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if ! docker info > /dev/null 2>&1; then
echo "This script uses docker, and it isn't running - please start docker and try again!"
@ -10,14 +10,14 @@ fi
############################################################
Help()
{
# Display Help
echo "Bootstraps a docker image for contributing changes to doom-nvim"
echo
echo "Syntax: ./start_docker.sh [-b <branc_name>]"
echo "options:"
echo "-b Create a new branch for the contribution"
echo "-h Shows this help menu"
echo
# Display Help
echo "Bootstraps a docker image for contributing changes to doom-nvim"
echo
echo "Syntax: ./start_docker.sh [-b <branch_name>]"
echo "options:"
echo "-b Create a new branch for the contribution"
echo "-h Shows this help menu"
echo
}
# Get directory of script
@ -27,49 +27,54 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BRANCH_NAME=doom-nvim-contrib # Branch to checkout / create
while getopts "b:h" option; do
case $option in
b) # set branch name
BRANCH_NAME=$OPTARG
echo "Setting branchname to $OPTARG"
;;
h) # display Help
Help
exit;;
esac
case $option in
b) # set branch name
BRANCH_NAME=$OPTARG
echo "Setting branchname to $OPTARG"
;;
h) # display Help
Help
exit;;
*)
Help
exit;;
esac
done
cd "$SCRIPT_DIR" || exit
# Create the worktree if it doesn't already exist
if [[ ! -d ./doom-nvim-contrib ]]; then
if [[ ! -d "$SCRIPT_DIR"/doom-nvim-contrib ]]; then
echo "0. Creating new git worktree of doom-nvim at $SCRIPT_DIR/doom-nvim-contrib"
git worktree add ./doom-nvim-contrib origin/develop -b $BRANCH_NAME -f
git worktree add ./doom-nvim-contrib origin/develop -b "$BRANCH_NAME" -f
fi
# CD into worktree
cd ./doom-nvim-contrib
cd ./doom-nvim-contrib || exit
echo "1. Setting up branch"
# If branch exists just check it out
if git show-ref --quiet refs/heads/$BRANCH_NAME; then
if [[ ! `git rev-parse --abbrev-ref HEAD` == $BRANCH_NAME ]]; then
if git show-ref --quiet refs/heads/"$BRANCH_NAME"; then
if [[ ! $( git rev-parse --abbrev-ref HEAD ) == "$BRANCH_NAME" ]]; then
echo " - Checking out branch $BRANCH_NAME..."
git checkout $BRANCH_NAME
git checkout "$BRANCH_NAME"
fi
else
# Pull latest version of develop
echo " - Creating new branch off develop..."
git checkout -b $BRANCH_NAME develop
git checkout -b "$BRANCH_NAME" develop
git fetch --quiet
# If changes between local and origin, get latest changes
if [[ ! `git rev-list develop...origin/develop --count` -eq 0 ]]; then
if [[ ! $( git rev-list develop...origin/develop --count ) -eq 0 ]]; then
echo " - WARN: There are upstream changes to develop branch. Please pull latest changes"
read -p " Do you want to continue creating $BRANCH_NAME? (y/n) " -n 1 -r
fi
# Create new branch for feature and check it out
echo " - Creating new branch $BRANCH_NAME..."
git checkout -b $BRANCH_NAME
git checkout -b "$BRANCH_NAME"
fi
cd ..
cd .. || exit
echo " - Success! Checked out $BRANCH_NAME branch at:"
echo " $SCRIPT_DIR/doom-nvim-contrib"
echo ""
@ -82,9 +87,9 @@ if [[ ! "$(docker images -q doom-nvim-contrib)" ]]; then
fi
if [ "$(docker ps -aq -f status=exited -f name=doom-nvim-contrib-container)" ]; then
echo " - Cleaning up old container..."
# cleanup
docker rm doom-nvim-contrib-container >> /dev/null
echo " - Cleaning up old container..."
# cleanup
docker rm doom-nvim-contrib-container >> /dev/null
fi
# Create docker container if haven't already
@ -94,9 +99,9 @@ docker run \
-it \
-e UID="1000" \
-e GID="1000" \
-v $SCRIPT_DIR/doom-nvim-contrib:/home/doom/.config/nvim \
-v $SCRIPT_DIR/local-share-nvim:/home/doom/.local/share/nvim \
-v $SCRIPT_DIR/workspace:/home/doom/workspace \
-v "$SCRIPT_DIR"/doom-nvim-contrib:/home/doom/.config/nvim \
-v "$SCRIPT_DIR"/local-share-nvim:/home/doom/.local/share/nvim \
-v "$SCRIPT_DIR"/workspace:/home/doom/workspace \
--name doom-nvim-contrib-container \
--user doom \
doom-nvim-contrib

12
docs/contributing.md

@ -32,6 +32,8 @@ will have less settings and plugins than you personal branch and therefore it wi
not work as expected otherwise. Eg. you will see 'Dashboard' text on vim load instead of
'Doom'.
> Alternatively you can setup an isolated dev environment for contributing using our docker image [here](../contribute/README.md#doom-contrib-docker-image-start_dockersh).
## Reporting issues
### Acquire a backtrace from errors
@ -116,3 +118,13 @@ your pull request :)
[gist]: https://gist.github.com/
[stylua]: https://github.com/JohnnyMorganz/StyLua
[luacheck]:https://github.com/luarocks/luacheck
### Tools
A range of tools for contributors are currently housed in the `contribute/` folder.
Read the detailed [documentation](../contribute/README.md).
#### Notable Tools
- [`contribute/start_docker.sh`](../contribute/README.md#doom-contrib-docker-image-start_dockersh) Sets up a dev environment for contributing to doom-nvim. Creates a git worktree to make changes and a docker image to test them within.

Loading…
Cancel
Save