mirror of
https://github.com/outbackdingo/ghorg.git
synced 2026-01-27 10:19:03 +00:00
Update config init to read in config file (#141)
* Update config init to read in config file
This commit is contained in:
4
.github/workflows/go.yml
vendored
4
.github/workflows/go.yml
vendored
@@ -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:
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user