print repo info for status commands
This commit is contained in:
parent
6a6a6cc60f
commit
d64dcdca95
5 changed files with 71 additions and 4 deletions
33
context/formatted.go
Normal file
33
context/formatted.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package context
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cli/cli/internal/ghrepo"
|
||||
"github.com/cli/cli/utils"
|
||||
)
|
||||
|
||||
func FormattedInfo(c Context, parentRepo string) (string, error) {
|
||||
baseRepo, err := c.BaseRepo()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
authLogin, err := c.AuthLogin()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
forkInfo := ""
|
||||
if parentRepo != "" {
|
||||
forkInfo = fmt.Sprintf("(fork of %s) ", parentRepo)
|
||||
}
|
||||
|
||||
out := fmt.Sprintf("%s%s %s%s%s",
|
||||
utils.Gray("in "),
|
||||
utils.Magenta(ghrepo.FullName(baseRepo)),
|
||||
utils.Yellow(forkInfo),
|
||||
utils.Gray("as "),
|
||||
utils.Magenta(authLogin),
|
||||
)
|
||||
|
||||
return out, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue