Skip to content

Commit

Permalink
Merge pull request #77 from gabrie30/vendoring
Browse files Browse the repository at this point in the history
add vendoring and some minor improvements
  • Loading branch information
gabrie30 authored Jul 11, 2020
2 parents 9f14d10 + 3aa1e8b commit ce89eb8
Show file tree
Hide file tree
Showing 1,286 changed files with 419,115 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ghorg
.env
debug
.DS_Store
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [1.3.2 - Unreleased] - DATE
## [1.3.0] - 07/11/20
### Added
- auto downcase of ghorg clone folder name; thanks @zamariola
- auto underscore of ghorg clone folder name
- vendoring of dependencies
- go modules
- easter egg
### Changed
- ghorg configuration location to $HOME/.config/ghorg or $XDG_CONFIG_HOME https://github.com/gabrie30/ghorg/issues/65; thanks @liljenstolpe
### Deprecated
### Removed
### Fixed
- version number to 1.3.0; thanks @alexcurtin
### Security
- reset remote to not include apikey https://github.com/gabrie30/ghorg/issues/64; thanks @mcinerney

Expand Down
24 changes: 20 additions & 4 deletions cmd/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
color string
baseURL string
concurrency string
outputDir string
skipArchived bool
backup bool
args []string
Expand All @@ -58,6 +59,7 @@ func init() {
cloneCmd.Flags().BoolVar(&backup, "backup", false, "GHORG_BACKUP backup mode, clone as mirror, no working copy (ignores branch parameter)")
cloneCmd.Flags().StringVarP(&baseURL, "base-url", "", "", "GHORG_SCM_BASE_URL change SCM base url, for on self hosted instances (currently gitlab only, use format of https://git.mydomain.com/api/v3)")
cloneCmd.Flags().StringVarP(&concurrency, "concurrency", "", "", "GHORG_CONCURRENCY max goroutines to spin up while cloning (default 25)")
cloneCmd.Flags().StringVarP(&outputDir, "output-dir", "", "", "GHORG_OUTPUT_DIR name of directory repos will be cloned into, will force underscores and always append _ghorg (default {org/repo being cloned}_ghorg)")

}

Expand Down Expand Up @@ -139,6 +141,11 @@ func cloneFunc(cmd *cobra.Command, argz []string) {
os.Setenv("GHORG_BACKUP", "true")
}

if cmd.Flags().Changed("output-dir") {
d := cmd.Flag("output-dir").Value.String()
os.Setenv("GHORG_OUTPUT_DIR", d)
}

configs.GetOrSetToken()

if cmd.Flags().Changed("token") {
Expand All @@ -165,7 +172,7 @@ func cloneFunc(cmd *cobra.Command, argz []string) {

parseParentFolder(argz)
args = argz
targetCloneSource = argz[0]
targetCloneSource = argz[0]

CloneAllRepos()
}
Expand Down Expand Up @@ -213,7 +220,7 @@ func getAllUserCloneUrls() ([]repo.Data, error) {
}

func createDirIfNotExist() {
if _, err := os.Stat(os.Getenv("GHORG_ABSOLUTE_PATH_TO_CLONE_TO") + parentFolder + "_ghorg"); os.IsNotExist(err) {
if _, err := os.Stat(os.Getenv("GHORG_ABSOLUTE_PATH_TO_CLONE_TO") + parentFolder + "_ghorg"); os.IsNotExist(err) {
err = os.MkdirAll(os.Getenv("GHORG_ABSOLUTE_PATH_TO_CLONE_TO"), 0700)
if err != nil {
panic(err)
Expand Down Expand Up @@ -268,7 +275,9 @@ func readGhorgIgnore() ([]string, error) {
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
if scanner.Text() != "" {
lines = append(lines, scanner.Text())
}
}
return lines, scanner.Err()
}
Expand Down Expand Up @@ -312,6 +321,7 @@ func CloneAllRepos() {
}

colorlog.PrintInfo("Using ghorgignore, filtering repos down...")
fmt.Println("")

filteredCloneTargets := []repo.Data{}
var flag bool
Expand Down Expand Up @@ -509,5 +519,11 @@ func addTokenToHTTPSCloneURL(url string, token string) string {
}

func parseParentFolder(argz []string) {
parentFolder = strings.ToLower(argz[0])
if os.Getenv("GHORG_OUTPUT_DIR") != "" {
parentFolder = strings.ReplaceAll(os.Getenv("GHORG_OUTPUT_DIR"), "-", "_")
return
}

pf := strings.ReplaceAll(argz[0], "-", "_")
parentFolder = strings.ToLower(pf)
}
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ var versionCmd = &cobra.Command{
Short: "Print the version number of Ghorg",
Long: `All software has versions. This is Ghorg's`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("1.3.2")
fmt.Println("1.3.0")
},
}
1 change: 1 addition & 0 deletions configs/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func initConfig() {
getOrSetDefaults("GHORG_BITBUCKET_APP_PASSWORD")
getOrSetDefaults("GHORG_SCM_BASE_URL")
getOrSetDefaults("GHORG_PRESERVE_DIRECTORY_STRUCTURE")
getOrSetDefaults("GHORG_OUTPUT_DIR")
}

// Load triggers the configs to load first, not sure if this is actually needed
Expand Down
34 changes: 34 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module github.com/gabrie30/ghorg

go 1.14

require (
github.com/fatih/color v1.9.0
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/google/go-github/v32 v32.0.0
github.com/gorilla/mux v1.7.4
github.com/hashicorp/go-retryablehttp v0.6.6 // indirect
github.com/k0kubun/pp v3.0.1+incompatible // indirect
github.com/korovkin/limiter v0.0.0-20190919045942-dac5a6b2a536
github.com/ktrysmt/go-bitbucket v0.6.1
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/pelletier/go-toml v1.8.0 // indirect
github.com/prometheus/client_golang v1.7.1
github.com/spf13/afero v1.3.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.0
github.com/xanzy/go-gitlab v0.33.0
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/ini.v1 v1.57.0 // indirect
)
Loading

0 comments on commit ce89eb8

Please sign in to comment.