1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-04 22:34:39 +02:00
Stefan Haller d890c68cd0 Add ahead/behind information for @{push}
In a triangular workflow the branch that you're pulling from is not the same as
the one that you are pushing to. For example, some people find it useful to set
the upstream branch to origin/master so that pulling effectively rebases onto
master, and set the push.default git config to "current" so that "feature"
pushes to origin/feature.

Another example is a fork-based workflow where "feature" has upstream set to
upstream/main, and the repo has remote.pushDefault set to "origin", so pushing
on "feature" pushes to origin/feature.

This commit adds new fields to models.Branch that store the ahead/behind
information against the push branch; for the "normal" workflow where you pull
and push from/to the upstream branch, AheadForPush/BehindForPush will be the
same as AheadForPull/BehindForPull.
2024-05-19 09:44:38 +02:00

101 lines
2.3 KiB
Go

package custom_commands
import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/stefanhaller/git-todo-parser/todo"
)
// We create shims for all the model classes in order to get a more stable API
// for custom commands. At the moment these are almost identical to the model
// classes, but this allows us to add "private" fields to the model classes that
// we don't want to expose to custom commands, or rename a model field to a
// better name without breaking people's custom commands. In such a case we add
// the new, better name to the shim but keep the old one for backwards
// compatibility. We already did this for Commit.Sha, which was renamed to Hash.
type Commit struct {
Hash string // deprecated: use Sha
Sha string
Name string
Status models.CommitStatus
Action todo.TodoCommand
Tags []string
ExtraInfo string
AuthorName string
AuthorEmail string
UnixTimestamp int64
Divergence models.Divergence
Parents []string
}
type File struct {
Name string
PreviousName string
HasStagedChanges bool
HasUnstagedChanges bool
Tracked bool
Added bool
Deleted bool
HasMergeConflicts bool
HasInlineMergeConflicts bool
DisplayString string
ShortStatus string
IsWorktree bool
}
type Branch struct {
Name string
DisplayName string
Recency string
Pushables string // deprecated: use AheadForPull
Pullables string // deprecated: use BehindForPull
AheadForPull string
BehindForPull string
AheadForPush string
BehindForPush string
UpstreamGone bool
Head bool
DetachedHead bool
UpstreamRemote string
UpstreamBranch string
Subject string
CommitHash string
}
type RemoteBranch struct {
Name string
RemoteName string
}
type Remote struct {
Name string
Urls []string
Branches []*RemoteBranch
}
type Tag struct {
Name string
Message string
}
type StashEntry struct {
Index int
Recency string
Name string
}
type CommitFile struct {
Name string
ChangeStatus string
}
type Worktree struct {
IsMain bool
IsCurrent bool
Path string
IsPathMissing bool
GitDir string
Branch string
Name string
}