2022-09-01 20:25:41 +02:00
|
|
|
package models
|
|
|
|
|
2023-07-16 05:43:20 +02:00
|
|
|
// A git worktree
|
2022-09-01 20:25:41 +02:00
|
|
|
type Worktree struct {
|
2023-07-16 05:43:20 +02:00
|
|
|
// if false, this is a linked worktree
|
2023-07-16 03:36:50 +02:00
|
|
|
IsMain bool
|
2023-07-28 08:17:15 +02:00
|
|
|
// if true, this is the worktree that is currently checked out
|
|
|
|
IsCurrent bool
|
2023-07-24 08:36:11 +02:00
|
|
|
// path to the directory of the worktree i.e. the directory that contains all the user's files
|
|
|
|
Path string
|
2023-07-28 08:17:15 +02:00
|
|
|
// if true, the path is not found
|
|
|
|
IsPathMissing bool
|
2023-07-24 08:36:11 +02:00
|
|
|
// path of the git directory for this worktree. The equivalent of the .git directory
|
|
|
|
// in the main worktree. For linked worktrees this would be <repo_path>/.git/worktrees/<name>
|
|
|
|
GitDir string
|
|
|
|
// If the worktree has a branch checked out, this field will be set to the branch name.
|
|
|
|
// A branch is considered 'checked out' if:
|
|
|
|
// * the worktree is directly on the branch
|
|
|
|
// * the worktree is mid-rebase on the branch
|
|
|
|
// * the worktree is mid-bisect on the branch
|
2022-09-03 05:08:36 +02:00
|
|
|
Branch string
|
2023-07-24 08:36:11 +02:00
|
|
|
// based on the path, but uniquified. Not the same name that git uses in the worktrees/ folder (no good reason for this,
|
|
|
|
// I just prefer my naming convention better)
|
2023-07-28 10:53:00 +02:00
|
|
|
Name string
|
2022-09-01 20:25:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Worktree) RefName() string {
|
2023-07-28 10:53:00 +02:00
|
|
|
return w.Name
|
2022-09-01 20:25:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Worktree) ID() string {
|
2023-07-16 05:43:20 +02:00
|
|
|
return w.Path
|
2022-09-01 20:25:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Worktree) Description() string {
|
|
|
|
return w.RefName()
|
|
|
|
}
|