Update config init to read in config file (#141)

* Update config init to read in config file
This commit is contained in:
Jay Gabriels
2021-08-11 07:49:17 -07:00
committed by GitHub
parent 3c6fb5c4d5
commit b7ab5bcf2e
4 changed files with 20 additions and 9 deletions

View File

@@ -16,6 +16,8 @@ jobs:
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Test
run: go test -v ./...
- name: Set configuration file
run: |
echo $HOME
@@ -26,8 +28,6 @@ jobs:
go get -v -t -d ./...
- name: Build
run: go build -v -o ghorg .
- name: Test
run: go test -v ./...
- name: Run GitHub Integration Tests
run: scripts/github_integration_tests.sh
env:

View File

@@ -116,6 +116,7 @@ $ security find-internet-password -s gitlab.com | grep "acct" | awk -F\" '{ pri
## Filtering Repos
- To filter repos by regex use `--match-regex` flag
- To filter out any archived repos while cloning use the `--skip-archived` flag (not bitbucket)
- To filter out any forked repos while cloning use the `--skip-forks` flag
- To ignore specific repos create a `ghorgignore` file inside `$HOME/.config/ghorg`. Each line in this file is considered a substring and will be compared against each repos clone url. If the clone url contains a substring in the `ghorgignore` it will be excluded from cloning. To prevent accidentally excluding a repo, you should make each line as specific as possible, eg. `https://github.com/gabrie30/ghorg.git` or `git@github.com:gabrie30/ghorg.git` depending on how you clone. This is useful for permanently igorning certain repos.

View File

@@ -67,11 +67,12 @@ func printGhorgConfMissing() {
}
func initConfig() {
ghorgDir := GhorgDir()
viper.SetConfigType("yaml")
viper.AddConfigPath(ghorgDir)
viper.AddConfigPath(GhorgDir())
viper.SetConfigName("conf")
viper.ReadInConfig()
// Set With Default values
getOrSetDefaults("GHORG_ABSOLUTE_PATH_TO_CLONE_TO")
getOrSetDefaults("GHORG_BRANCH")

View File

@@ -10,13 +10,18 @@ GITHUB_ORG=underdeveloped
ghorg version
# hack to allow sed to be ran on both mac and ubuntu
sed "s/GHORG_OUTPUT_DIR:/GHORG_OUTPUT_DIR: testing_conf_is_set/g" $HOME/.config/ghorg/conf.yaml >updated_conf.yaml && \
mv $HOME/.config/ghorg/conf.yaml $HOME/.config/ghorg/conf-bak.yaml && \
mv updated_conf.yaml $HOME/.config/ghorg/conf.yaml
ghorg clone $GITHUB_ORG --token=$GITHUB_TOKEN
if [ -e $HOME/ghorg/$GITHUB_ORG ]
if [ -e $HOME/ghorg/testing_conf_is_set ]
then
echo "Pass: github org clone"
echo "Pass: github org clone using conf.yaml"
else
echo "Fail: github org clone"
echo "Fail: github org clone using conf.yaml"
exit 1
fi
@@ -24,8 +29,12 @@ ghorg clone $GITHUB_ORG --token=$GITHUB_TOKEN --path=/tmp --output-dir=testing_o
if [ -e /tmp/testing_output_dir ]
then
echo "Pass: github org clone custom output directories"
echo "Pass: github org clone, commandline flags take overwrite conf.yaml"
else
echo "Fail: github org clone custom output directories"
echo "Fail: github org clone, commandline flags take overwrite conf.yaml"
exit 1
fi
# Move back to original conf but keep updated_conf if we want to use it again
mv $HOME/.config/ghorg/conf.yaml $HOME/.config/ghorg/updated_conf.yaml
mv $HOME/.config/ghorg/conf-bak.yaml $HOME/.config/ghorg/conf.yaml