Skip to content

Commit

Permalink
fix(cdsctl): ask for context in shell only if current directory is a …
Browse files Browse the repository at this point in the history
…repository (#3775)
  • Loading branch information
richardlt authored and yesnault committed Dec 31, 2018
1 parent 3b5d805 commit 77e73cf
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cli/cdsctl/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,22 @@ func shellRun(v cli.Values) error {
EOFPrompt: "exit",
HistorySearchFold: true,
})

if err != nil {
fmt.Printf("Error: %s\n", err)
}

defer l.Close()

home := "/"
// auto-discover current project with .git
if _, err := discoverConf([]cli.Arg{
{Name: _ProjectKey},
{Name: _ApplicationName, AllowEmpty: true},
{Name: _WorkflowName, AllowEmpty: true},
}); err == nil {
if r, err := repo.New("."); err == nil {

// try to discover conf for existing .git repository
r, errR := repo.New(".")
if errR == nil {
if _, err := discoverConf([]cli.Arg{
{Name: _ProjectKey},
{Name: _ApplicationName, AllowEmpty: true},
{Name: _WorkflowName, AllowEmpty: true},
}); err == nil {
if proj, _ := r.LocalConfigGet("cds", "project"); proj != "" {
home = "/project/" + proj
if wf, _ := r.LocalConfigGet("cds", "workflow"); wf != "" {
Expand All @@ -110,8 +111,8 @@ func shellRun(v cli.Values) error {
}
}
}
current.home = home

current.home = home
current.path = home

for {
Expand Down

0 comments on commit 77e73cf

Please sign in to comment.