Skip to content

Commit

Permalink
feat: Change how rename happens and document it.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Jan 10, 2024
1 parent 8fd8ece commit a822866
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ ph update
ph wdid 2 days
```

## Config

```yaml
# The root of all projects
basedir: /home/username/src

# Rename repository hosts to an alias for using different ssh keys
renameRepo:
gh-personal: github.com/nousefreak
gh-work: github.com/stenic
```
## Badges
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/command/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func cloneRepo(repo string) (string, error) {
}

func makeURL(u *url.URL, renameRepo map[string]string) (string, error) {
for match, host := range renameRepo {
for host, match := range renameRepo {
r := regexp.MustCompile(regexp.QuoteMeta(match))
if r.MatchString(u.String()) {
u.Host = host
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/command/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Test_makeURL(t *testing.T) {
{
name: "notinma",
renameMap: map[string]string{
"bitbucket.org/bla/bla": "bb-personal",
"bb-personal": "bitbucket.org/bla/bla",
},
URL: "ssh://[email protected]/bla/bla",
want: "ssh://[email protected]/bla/bla",
Expand All @@ -32,7 +32,7 @@ func Test_makeURL(t *testing.T) {
{
name: "replace",
renameMap: map[string]string{
"github.com/bla": "gh-personal",
"gh-personal": "github.com/bla",
},
URL: "ssh://[email protected]/bla/bla",
want: "ssh://git@gh-personal/bla/bla",
Expand Down
3 changes: 3 additions & 0 deletions internal/pkg/command/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func getSetupCmd() *cobra.Command {
if err := viper.WriteConfig(); err != nil {
logrus.Fatal(err)
}

logrus.Info("Setup complete")
logrus.Info("If you want to make more advanced changes, edit the config file at ~/.config/project-helper/config.yaml")
},
}

Expand Down

0 comments on commit a822866

Please sign in to comment.