Skip to content

Commit

Permalink
feat: print clone url on repo create
Browse files Browse the repository at this point in the history
Prints the repo ssh clone url on create

Fixes: #297
  • Loading branch information
aymanbagabas committed Aug 4, 2023
1 parent eaf3619 commit c7829a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
14 changes: 12 additions & 2 deletions server/ssh/cmd/create.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package cmd

import (
"fmt"

"github.com/charmbracelet/soft-serve/server/backend"
"github.com/charmbracelet/soft-serve/server/config"
"github.com/charmbracelet/soft-serve/server/proto"
"github.com/spf13/cobra"
)
Expand All @@ -20,17 +23,24 @@ func createCommand() *cobra.Command {
PersistentPreRunE: checkIfCollab,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
cfg := config.FromContext(ctx)
be := backend.FromContext(ctx)
user := proto.UserFromContext(ctx)
name := args[0]
if _, err := be.CreateRepository(ctx, name, user, proto.RepositoryOptions{
r, err := be.CreateRepository(ctx, name, user, proto.RepositoryOptions{
Private: private,
Description: description,
ProjectName: projectName,
Hidden: hidden,
}); err != nil {
})
if err != nil {
return err
}

cloneurl := fmt.Sprintf("%s/%s.git", cfg.SSH.PublicURL, r.Name())
cmd.PrintErrf("Created repository %s\n", r.Name())
cmd.Println(cloneurl)

return nil
},
}
Expand Down
3 changes: 1 addition & 2 deletions testscript/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ func TestScript(t *testing.T) {
cfg.Stats.ListenAddr = statsListen
cfg.DB.Driver = "sqlite"
cfg.LFS.Enabled = true
// TODO: run tests with both SSH enabled/disabled
cfg.LFS.SSHEnabled = false
cfg.LFS.SSHEnabled = true

if err := cfg.Validate(); err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/repo-create.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# create a repo
soft repo create repo1 -d 'description' -H -p -n 'repo11'
stderr 'Created repository repo1.*'
stdout ssh://localhost:$SSH_PORT/repo1.git
soft repo hidden repo1
stdout true
soft repo private repo1
Expand Down Expand Up @@ -95,6 +97,8 @@ soft user create bar --key "$USER1_AUTHORIZED_KEY"

# user create a repo
usoft repo create repo2 -d 'description' -H -p -n 'repo2'
stderr 'Created repository repo2.*'
stdout ssh://localhost:$SSH_PORT/repo2.git
usoft repo hidden repo2
stdout true
usoft repo private repo2
Expand Down

0 comments on commit c7829a3

Please sign in to comment.