feat(sapling): identify new repo without commits

This commit is contained in:
Jan De Dobbeleer 2023-04-08 10:59:37 +02:00 committed by Jan De Dobbeleer
parent a58aebcd5c
commit 2d0ee8c8ab
2 changed files with 20 additions and 12 deletions

View file

@ -52,6 +52,7 @@ type Sapling struct {
Author string
Bookmark string
Description string
New bool
Working *SaplingStatus
}
@ -129,6 +130,10 @@ func (sl *Sapling) setHeadContext() {
func (sl *Sapling) setCommitContext() {
body := sl.getSaplingCommandOutput("log", "--limit", "1", "--template", SLCOMMITTEMPLATE)
if len(body) == 0 {
sl.New = true
return
}
splitted := strings.Split(strings.TrimSpace(body), "\n")
for _, line := range splitted {
line = strings.TrimSpace(line)

View file

@ -10,19 +10,21 @@ Display [sapling][sapling] information when in a sapling repository.
## Sample Configuration
import Config from '@site/src/components/Config.js';
import Config from "@site/src/components/Config.js";
<Config data={{
"type": "sapling",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#4C9642",
"background_templates": ["{{ if .Bookmark }}#4C9642{{ end }}"],
"properties": {
"fetch_status": true
}
}}/>
<Config
data={{
type: "sapling",
style: "powerline",
powerline_symbol: "\uE0B0",
foreground: "#193549",
background: "#4C9642",
background_templates: ["{{ if .Bookmark }}#4C9642{{ end }}"],
properties: {
fetch_status: true,
},
}}
/>
## Properties
@ -56,6 +58,7 @@ import Config from '@site/src/components/Config.js';
| `.When` | `string` | the commit's relative time indication |
| `.Bookmark` | `string` | the commit's bookmark (if any) |
| `.Dir` | `string` | the repository's root directory |
| `.New` | `boolean` | true when there are no commits in the repo |
### SaplingStatus