mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
parent
bba8c040c2
commit
3b40f825c3
|
@ -129,28 +129,35 @@ const (
|
||||||
trueStr = "true"
|
trueStr = "true"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Rebase struct {
|
||||||
|
HEAD string
|
||||||
|
Onto string
|
||||||
|
Current int
|
||||||
|
Total int
|
||||||
|
}
|
||||||
|
|
||||||
type Git struct {
|
type Git struct {
|
||||||
User *User
|
User *User
|
||||||
Working *GitStatus
|
Working *GitStatus
|
||||||
Staging *GitStatus
|
Staging *GitStatus
|
||||||
commit *Commit
|
commit *Commit
|
||||||
UpstreamURL string
|
Rebase *Rebase
|
||||||
UpstreamIcon string
|
RawUpstreamURL string
|
||||||
Ref string
|
Ref string
|
||||||
Hash string
|
Hash string
|
||||||
ShortHash string
|
ShortHash string
|
||||||
BranchStatus string
|
BranchStatus string
|
||||||
Upstream string
|
Upstream string
|
||||||
HEAD string
|
HEAD string
|
||||||
RawUpstreamURL string
|
UpstreamIcon string
|
||||||
|
UpstreamURL string
|
||||||
scm
|
scm
|
||||||
Ahead int
|
|
||||||
stashCount int
|
|
||||||
worktreeCount int
|
worktreeCount int
|
||||||
|
stashCount int
|
||||||
Behind int
|
Behind int
|
||||||
|
Ahead int
|
||||||
IsWorkTree bool
|
IsWorkTree bool
|
||||||
Merge bool
|
Merge bool
|
||||||
Rebase bool
|
|
||||||
CherryPick bool
|
CherryPick bool
|
||||||
Revert bool
|
Revert bool
|
||||||
poshgit bool
|
poshgit bool
|
||||||
|
@ -587,7 +594,7 @@ func (g *Git) setGitStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// map conflicts separately when in a merge or rebase
|
// map conflicts separately when in a merge or rebase
|
||||||
if g.Rebase || g.Merge {
|
if g.Rebase != nil || g.Merge {
|
||||||
conflict := "AA"
|
conflict := "AA"
|
||||||
full := status[2:4]
|
full := status[2:4]
|
||||||
if full == conflict {
|
if full == conflict {
|
||||||
|
@ -698,25 +705,43 @@ func (g *Git) setGitHEADContext() {
|
||||||
return origin
|
return origin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseInt := func(file string) int {
|
||||||
|
val, _ := strconv.Atoi(g.FileContents(g.workingDir, file))
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
if g.env.HasFolder(g.workingDir + "/rebase-merge") {
|
if g.env.HasFolder(g.workingDir + "/rebase-merge") {
|
||||||
g.Rebase = true
|
head := getPrettyNameOrigin("rebase-merge/head-name")
|
||||||
origin := getPrettyNameOrigin("rebase-merge/head-name")
|
|
||||||
onto := g.getGitRefFileSymbolicName("rebase-merge/onto")
|
onto := g.getGitRefFileSymbolicName("rebase-merge/onto")
|
||||||
onto = g.formatBranch(onto)
|
onto = g.formatBranch(onto)
|
||||||
step := g.FileContents(g.workingDir, "rebase-merge/msgnum")
|
current := parseInt("rebase-merge/msgnum")
|
||||||
total := g.FileContents(g.workingDir, "rebase-merge/end")
|
total := parseInt("rebase-merge/end")
|
||||||
icon := g.props.GetString(RebaseIcon, "\uE728 ")
|
icon := g.props.GetString(RebaseIcon, "\uE728 ")
|
||||||
g.HEAD = fmt.Sprintf("%s%s onto %s%s (%s/%s) at %s", icon, origin, branchIcon, onto, step, total, g.HEAD)
|
|
||||||
|
g.Rebase = &Rebase{
|
||||||
|
HEAD: head,
|
||||||
|
Onto: onto,
|
||||||
|
Current: current,
|
||||||
|
Total: total,
|
||||||
|
}
|
||||||
|
|
||||||
|
g.HEAD = fmt.Sprintf("%s%s onto %s%s (%d/%d) at %s", icon, head, branchIcon, onto, current, total, g.HEAD)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.env.HasFolder(g.workingDir + "/rebase-apply") {
|
if g.env.HasFolder(g.workingDir + "/rebase-apply") {
|
||||||
g.Rebase = true
|
head := getPrettyNameOrigin("rebase-apply/head-name")
|
||||||
origin := getPrettyNameOrigin("rebase-apply/head-name")
|
current := parseInt("rebase-apply/next")
|
||||||
step := g.FileContents(g.workingDir, "rebase-apply/next")
|
total := parseInt("rebase-apply/last")
|
||||||
total := g.FileContents(g.workingDir, "rebase-apply/last")
|
|
||||||
icon := g.props.GetString(RebaseIcon, "\uE728 ")
|
icon := g.props.GetString(RebaseIcon, "\uE728 ")
|
||||||
g.HEAD = fmt.Sprintf("%s%s (%s/%s) at %s", icon, origin, step, total, g.HEAD)
|
|
||||||
|
g.Rebase = &Rebase{
|
||||||
|
HEAD: head,
|
||||||
|
Current: current,
|
||||||
|
Total: total,
|
||||||
|
}
|
||||||
|
|
||||||
|
g.HEAD = fmt.Sprintf("%s%s (%d/%d) at %s", icon, head, current, total, g.HEAD)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -590,10 +590,15 @@ func TestSetGitStatus(t *testing.T) {
|
||||||
if tc.ExpectedWorking == nil {
|
if tc.ExpectedWorking == nil {
|
||||||
tc.ExpectedWorking = &GitStatus{}
|
tc.ExpectedWorking = &GitStatus{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if tc.ExpectedStaging == nil {
|
if tc.ExpectedStaging == nil {
|
||||||
tc.ExpectedStaging = &GitStatus{}
|
tc.ExpectedStaging = &GitStatus{}
|
||||||
}
|
}
|
||||||
g.Rebase = tc.Rebase
|
|
||||||
|
if tc.Rebase {
|
||||||
|
g.Rebase = &Rebase{}
|
||||||
|
}
|
||||||
|
|
||||||
g.Merge = tc.Merge
|
g.Merge = tc.Merge
|
||||||
tc.ExpectedStaging.Formats = map[string]string{}
|
tc.ExpectedStaging.Formats = map[string]string{}
|
||||||
tc.ExpectedWorking.Formats = map[string]string{}
|
tc.ExpectedWorking.Formats = map[string]string{}
|
||||||
|
|
|
@ -139,12 +139,12 @@ You can set the following properties to `true` to enable fetching additional inf
|
||||||
| `.Commit` | `Commit` | HEAD commit information (see below) |
|
| `.Commit` | `Commit` | HEAD commit information (see below) |
|
||||||
| `.Detached` | `boolean` | true when the head is detached |
|
| `.Detached` | `boolean` | true when the head is detached |
|
||||||
| `.Merge` | `boolean` | true when in a merge |
|
| `.Merge` | `boolean` | true when in a merge |
|
||||||
| `.Rebase` | `boolean` | true when in a rebase |
|
| `.Rebase` | `Rebase` | contains the relevant information when in a rebase |
|
||||||
| `.CherryPick` | `boolean` | true when in a cherry pick |
|
| `.CherryPick` | `boolean` | true when in a cherry pick |
|
||||||
| `.Revert` | `boolean` | true when in a revert |
|
| `.Revert` | `boolean` | true when in a revert |
|
||||||
| `.LatestTag` | `string` | the latest tag name |
|
| `.LatestTag` | `string` | the latest tag name |
|
||||||
|
|
||||||
### Status
|
#### Status
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------ | --------- | -------------------------------------------- |
|
| ------------ | --------- | -------------------------------------------- |
|
||||||
|
@ -166,7 +166,7 @@ Local changes use the following syntax:
|
||||||
| `~` | Modified |
|
| `~` | Modified |
|
||||||
| `?` | Untracked |
|
| `?` | Untracked |
|
||||||
|
|
||||||
### Commit
|
#### Commit
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------ | ----------- | --------------------------------------- |
|
| ------------ | ----------- | --------------------------------------- |
|
||||||
|
@ -177,14 +177,14 @@ Local changes use the following syntax:
|
||||||
| `.Sha` | `string` | the commit SHA1 |
|
| `.Sha` | `string` | the commit SHA1 |
|
||||||
| `.Refs` | `Refs` | the commit references |
|
| `.Refs` | `Refs` | the commit references |
|
||||||
|
|
||||||
### User
|
##### User
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| -------- | -------- | ---------------- |
|
| -------- | -------- | ---------------- |
|
||||||
| `.Name` | `string` | the user's name |
|
| `.Name` | `string` | the user's name |
|
||||||
| `.Email` | `string` | the user's email |
|
| `.Email` | `string` | the user's email |
|
||||||
|
|
||||||
### Refs
|
##### Refs
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ---------- | ---------- | ----------------- |
|
| ---------- | ---------- | ----------------- |
|
||||||
|
@ -198,6 +198,15 @@ As these are arrays of strings, you can join them using the `join` function:
|
||||||
{{ join ", " .Commit.Refs.Tags }}
|
{{ join ", " .Commit.Refs.Tags }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Rebase
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---------- | -------- | -------------------------------- |
|
||||||
|
| `.Current` | `int` | the current rebase step |
|
||||||
|
| `.Total` | `int` | the total number of rebase steps |
|
||||||
|
| `.HEAD` | `string` | the current HEAD |
|
||||||
|
| `.Onto` | `string` | the branch we're rebasing onto |
|
||||||
|
|
||||||
## posh-git
|
## posh-git
|
||||||
|
|
||||||
If you want to display the default [posh-git][poshgit] output, **do not** use this segment
|
If you want to display the default [posh-git][poshgit] output, **do not** use this segment
|
||||||
|
|
Loading…
Reference in a new issue