Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
Use GH CLI for operations (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Jun 28, 2020
1 parent 2caf882 commit f46e111
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 80 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"image": "ludeeus/container:monster",
"context": "..",
"appPort": ["9123:8123", "5000:5000", "3000:3000"],
"postStartCommand": "bash script/github_cli",
"runArgs": [
"-v",
"${env:HOME}${env:USERPROFILE}/.config/gh:/root/.config/gh"
],
"extensions": [
"github.vscode-pull-request-github",
"ms-python.python",
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
repositories
.gitssh
.gituser
repositories
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This repository contains all you need to contribute to the HACS project.

## Usage

1. Install and configure [gh CLI](https://github.com/cli/cli) on the host.
1. Fork this repository.
1. Clone the repository locally.
1. Start the devcontainer.
Expand Down
15 changes: 2 additions & 13 deletions script/development_init
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@

CURRENT_DIR=$(pwd)

source "${CURRENT_DIR}/script/helpers/git"

if [ ! -d ".git" ]; then
if [ ! -d "${CURRENT_DIR}/.git" ]; then
# No need to do anything
exit
fi

GITUSER=$(gitUser)
SSH=$(gitSSH)

if [ "$SSH" == "true" ]; then
git remote add upstream [email protected]:hacs/development.git
else
git remote add upstream https://github.com/hacs/development.git
fi

mv .git ..git
mv "${CURRENT_DIR}/.git" "${CURRENT_DIR}/..git"
7 changes: 5 additions & 2 deletions script/development_update
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
CURRENT_DIR=$(pwd)

mv "${CURRENT_DIR}/..git" "${CURRENT_DIR}/.git"

mv ..git .git
git pull upstream master
mv .git ..git

mv "${CURRENT_DIR}/.git" "${CURRENT_DIR}/..git"
5 changes: 0 additions & 5 deletions script/documentation_init
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

CURRENT_DIR=$(pwd)

if [ ! -d "${CURRENT_DIR}/repositories/documentation" ]; then
echo "Missing the repository, run 'make documentation-init'"
exit
fi

cd "${CURRENT_DIR}/repositories/documentation"

# Install pacakges
Expand Down
5 changes: 0 additions & 5 deletions script/frontend_init
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

CURRENT_DIR=$(pwd)

if [ ! -d "${CURRENT_DIR}/repositories/frontend" ]; then
echo "Missing the repository, run 'make frontend-init'"
exit
fi

cd "${CURRENT_DIR}/repositories/frontend"

# Install pacakges
Expand Down
13 changes: 13 additions & 0 deletions script/github_cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

if ! [ -x "$(command -v gh)" ]; then
apk add go
git clone https://github.com/cli/cli.git /srv/gh-cli
cd /srv/gh-cli
make
mv ./bin/gh /usr/local/bin/

if [[ $(git remote get-url origin) == *"git@github"* ]]; then
gh config set git_protocol ssh
fi
fi
37 changes: 0 additions & 37 deletions script/helpers/git

This file was deleted.

18 changes: 3 additions & 15 deletions script/repository_init
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
#!/usr/bin/env bash
source script/helpers/git

GITUSER=$(gitUser)
SSH=$(gitSSH)
CURRENT_DIR=$(pwd)
REPO=$1

echo $GITUSER
echo $SSH

mkdir -p ./repositories/${REPO}
cd ./repositories/${REPO}
git init
cd "${CURRENT_DIR}/repositories"

if [ "$SSH" == "true" ]; then
git remote add origin [email protected]:${GITUSER}/${REPO}.git
git remote add upstream [email protected]:hacs/${REPO}.git
else
git remote add origin https://github.com/${GITUSER}/${REPO}.git
git remote add upstream https://github.com/hacs/${REPO}.git
fi

git pull upstream master
gh repo fork hacs/"${REPO}" --clone=true --remote=true

0 comments on commit f46e111

Please sign in to comment.