fix: Resolved issue with local repos being private, using cli flag now
9d1ab967
4 file(s) · +29 −21
| 49 | 49 | brews: |
|
| 50 | 50 | - name: radicalize |
|
| 51 | 51 | homepage: "https://github.com/stevedylandev/radicalize" |
|
| 52 | - | description: "Migrate existing local and remote git repos to Radical" |
|
| 52 | + | description: "Migrate existing local and remote git repos to Radicle" |
|
| 53 | 53 | license: "MIT" |
|
| 54 | 54 | url_template: "https://github.com/stevedylandev/radicalize/releases/download/{{ .Tag }}/{{ .ArtifactName }}" |
|
| 55 | 55 | commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" |
| 1 | 1 | package main |
|
| 2 | 2 | ||
| 3 | 3 | import ( |
|
| 4 | - | "flag" |
|
| 5 | 4 | "fmt" |
|
| 6 | 5 | "os" |
|
| 7 | 6 | "os/exec" |
|
| 16 | 15 | Name string |
|
| 17 | 16 | } |
|
| 18 | 17 | ||
| 19 | - | var isPrivate bool |
|
| 20 | - | ||
| 21 | - | func LocalClone() error { |
|
| 22 | - | flag.BoolVar(&isPrivate, "private", false, "Initialize repositories as private") |
|
| 23 | - | flag.Parse() |
|
| 24 | - | ||
| 18 | + | func LocalClone(private bool) error { |
|
| 25 | 19 | repos := findGitRepos(".") |
|
| 26 | 20 | selectedRepos := selectLocalRepos(repos) |
|
| 27 | - | confirmAndInitRepos(selectedRepos) |
|
| 21 | + | confirmAndInitRepos(selectedRepos, private) |
|
| 28 | 22 | return nil |
|
| 29 | 23 | } |
|
| 30 | 24 | ||
| 88 | 82 | return selectedRepos |
|
| 89 | 83 | } |
|
| 90 | 84 | ||
| 91 | - | func confirmAndInitRepos(repos []Repo) { |
|
| 85 | + | func confirmAndInitRepos(repos []Repo, private bool) { |
|
| 92 | 86 | visibilityStr := "public" |
|
| 93 | - | if isPrivate { |
|
| 87 | + | if private { |
|
| 94 | 88 | visibilityStr = "private" |
|
| 95 | 89 | } |
|
| 96 | 90 | ||
| 109 | 103 | ||
| 110 | 104 | for i, repo := range repos { |
|
| 111 | 105 | fmt.Printf("Initializing %s (%d/%d)...\n", repo.Name, i+1, len(repos)) |
|
| 112 | - | err := runRadInit(repo.Path, repo.Name) |
|
| 106 | + | err := runRadInit(repo.Path, repo.Name, private) |
|
| 113 | 107 | if err != nil { |
|
| 114 | 108 | color.Red("Error initializing %s: %v\n", repo.Name, err) |
|
| 115 | 109 | } else { |
|
| 120 | 114 | fmt.Println("Radicalization Complete") |
|
| 121 | 115 | } |
|
| 122 | 116 | ||
| 123 | - | func runRadInit(path, name string) error { |
|
| 117 | + | func runRadInit(path, name string, private bool) error { |
|
| 124 | 118 | visibilityFlag := "--public" |
|
| 125 | - | if isPrivate { |
|
| 119 | + | if private { |
|
| 126 | 120 | visibilityFlag = "--private" |
|
| 127 | 121 | } |
|
| 128 | 122 | ||
| 46 | 46 | ||
| 47 | 47 | ## Usage |
|
| 48 | 48 | ||
| 49 | - | To start backing up your repos simply run the command `radicalize` in the parent directory of all your projects. This will creep through all directories for .git repos on a surface level, so if you have sub directories you will want to navigate to those separately. After finding all git repos you can select which ones you would like to init to your Radicle node. Once you have confirmed the selection it will work through each repo and initialize it. |
|
| 49 | + | This CLI (`radicalize`) has two commands: |
|
| 50 | + | ||
| 51 | + | ### `local` |
|
| 52 | + | ||
| 53 | + | To start backing up your local repos simply run the command `radicalize` in the parent directory of all your projects. This will creep through all directories for .git repos on a surface level, so if you have sub directories you will want to navigate to those separately. After finding all git repos you can select which ones you would like to init to your Radicle node. Once you have confirmed the selection it will work through each repo and initialize it. |
|
| 50 | 54 | ||
| 51 | 55 |  |
|
| 52 | 56 | ||
| 53 | - | ### Private Repos |
|
| 57 | + | **Private Repos** |
|
| 54 | 58 | ||
| 55 | 59 | By default the program will make repos public, however you can pass in the `--private` flag so all selected repos will be private instead |
|
| 56 | 60 | ||
| 57 | 61 | ``` |
|
| 58 | - | radicalize --private |
|
| 62 | + | radicalize local --private |
|
| 59 | 63 | ``` |
|
| 64 | + | ||
| 65 | + | ### `remote` |
| 10 | 10 | func main() { |
|
| 11 | 11 | app := &cli.App{ |
|
| 12 | 12 | Name: "radlicalize", |
|
| 13 | - | Usage: "A CLI tool used to clone either remote or local git repos to Radial.xyz", |
|
| 13 | + | Usage: "A CLI tool used to clone either remote or local git repos to Radicle.xyz", |
|
| 14 | 14 | Commands: []*cli.Command{ |
|
| 15 | 15 | { |
|
| 16 | 16 | Name: "local", |
|
| 17 | 17 | Aliases: []string{"l"}, |
|
| 18 | - | Usage: "Use to clone any local repos to Racial", |
|
| 18 | + | Usage: "Use to clone any local repos to Radicle", |
|
| 19 | + | Flags: []cli.Flag{ |
|
| 20 | + | &cli.BoolFlag{ |
|
| 21 | + | Name: "private", |
|
| 22 | + | Aliases: []string{"p"}, |
|
| 23 | + | Usage: "Use this flag if you want the repo to be private.", |
|
| 24 | + | }, |
|
| 25 | + | }, |
|
| 19 | 26 | Action: func(ctx *cli.Context) error { |
|
| 20 | - | return LocalClone() |
|
| 27 | + | private := ctx.Bool("private") |
|
| 28 | + | return LocalClone(private) |
|
| 21 | 29 | }, |
|
| 22 | 30 | }, |
|
| 23 | 31 | { |
|
| 24 | 32 | Name: "remote", |
|
| 25 | 33 | Aliases: []string{"r"}, |
|
| 26 | - | Usage: "Use to clone any remote public repos on Github to Racial", |
|
| 34 | + | Usage: "Use to clone any remote public repos on Github to Radicle", |
|
| 27 | 35 | Action: func(ctx *cli.Context) error { |
|
| 28 | 36 | return RemoteClone() |
|
| 29 | 37 | }, |