Class RepoState

java.lang.Object
io.github.jbastgen.stemma.app.model.RepoState

public final class RepoState extends Object
State of one open repository as the views see it. Real repositories are filled from the Git backend (SnapshotMapper) and changed only through it; the mutating methods below belong to the sample (demo) repositories, which live in memory.
  • Field Details

    • commits

      public List<Commit> commits
    • wip

      public List<FileChange> wip
    • branches

      public List<String> branches
    • remotes

      public List<Remote> remotes
    • remoteUrls

      public Map<String,String> remoteUrls
      The URL of each remote by its name (what git remote -v shows).
    • tags

      public List<String> tags
    • stashes

      public List<Stash> stashes
    • ahead

      public int ahead
    • behind

      public int behind
    • sel

      public String sel
      Selected commit id, or "wip" for the uncommitted changes row. With several commits selected: the one clicked last.
    • selection

      public final LinkedHashSet<String> selection
      All selected commit ids when the user selected several (Ctrl/Cmd-click, Shift-click). Only counts while it contains sel and has more than one entry, so setting sel alone always means "this one".
    • anchor

      public String anchor
      The commit a Shift-click extends the selection from.
    • msg

      public String msg
    • desc

      public String desc
    • templateBranch

      public String templateBranch
      The branch the message template was last put into the commit form for; null = not yet.
    • diff

      public DiffSel diff
    • real

      public boolean real
      true if loaded from a real repository, false for sample data.
    • totalCommits

      public int totalCommits
      Number of commits the Git backend returned (real repositories only).
    • mergeInProgress

      public boolean mergeInProgress
      A merge is in progress: conflicts wait to be resolved, then committed (real repositories only).
    • rebaseInProgress

      public boolean rebaseInProgress
      A rebase waits for conflicts to be resolved (real repositories only).
    • tagsRemote

      public String tagsRemote
      The remote whose tags were last asked for; empty = never asked.
    • remoteTagNames

      public Set<String> remoteTagNames
      The tags that tagsRemote had when it was asked, kept up to date by the pushes of this window; null = unknown.
    • sequence

      public io.github.jbastgen.stemma.git.api.SequenceKind sequence
      A cherry-pick or a revert waits for conflicts to be resolved (real repositories only).
    • fingerprint

      public int fingerprint
      What the last load looked like in short (changed files, branches, HEAD): a cheap check whether anything changed.
    • labelRepoKey

      public String labelRepoKey
      Identifies the repository in the label index (its first commit); empty until known or without commits.
    • pendingLabels

      public final LinkedHashSet<String> pendingLabels
      Labels (ids) chosen in the commit form for the next commit.
    • detachedHeadId

      public String detachedHeadId
      The commit HEAD points to when it is on no branch; empty otherwise.
    • upstream

      public String upstream
      Upstream branch of the current branch, e.g. origin/main; empty if there is none.
    • flowReady

      public boolean flowReady
      Git Flow is set up (production and development branch exist).
    • flowProduction

      public String flowProduction
    • flowDevelopment

      public String flowDevelopment
    • details

      public final Map<String,CommitDetail> details
      Message body and changed files per commit id, loaded on demand (real repositories only).
    • diffs

      public final Map<String,List<DiffLine>> diffs
      Diff lines per <commit id or "wip">:<path>, loaded on demand (real repositories only).
    • loading

      public final Set<String> loading
      Keys of loads that are running, so each is started once.
    • fileSel

      public final Set<String> fileSel
      Paths of the selected working-tree files; use selectedFiles() for the ones that are still there.
  • Constructor Details

    • RepoState

      public RepoState()
  • Method Details

    • sequenceInProgress

      public boolean sequenceInProgress()
      Whether a cherry-pick or revert is waiting for its conflicts.
    • branchCommit

      public Optional<Commit> branchCommit(String name)
      The commit a local branch points to.
    • remoteBranchCommit

      public Optional<Commit> remoteBranchCommit(String remote, String branch)
      The latest commit of a branch of a remote (branch without the remote's name), if it is in the loaded history.
    • squashChain

      public List<Commit> squashChain(Commit target)
      The commits from HEAD down to and including target, newest first, if they can be squashed into one: they follow each other as first parents and none of them is a merge commit. Empty otherwise, and for HEAD alone (one commit cannot be squashed).
    • firstParentChain

      public List<Commit> firstParentChain(Commit target)
      The commits from HEAD down to and including target, newest first, if they follow each other as first parents and none is a merge commit; empty otherwise. Unlike squashChain(io.github.jbastgen.stemma.app.model.Commit) one commit is enough.
    • onlyOnUpstream

      public List<Commit> onlyOnUpstream()
      The commits that the upstream branch has and the current branch has not (what a forced push would overwrite), newest first. Only those in the loaded history are found; empty when there is no upstream or its tip is not loaded.
    • headCommit

      public Commit headCommit()
      The commit HEAD is on: that of the current branch, or the detached one.
    • commit

      public Commit commit(String id)
      The commit with this id, or null.
    • target

      public Commit target()
      The commit that branch/tag actions apply to: the selection, or HEAD for the working tree.
    • selectedCommits

      public List<Commit> selectedCommits()
      The selected commits, newest first: several if the user selected several, one otherwise, none for the working tree.
    • multiSelected

      public boolean multiSelected()
      Whether more than one commit is selected.
    • isSelected

      public boolean isSelected(String commitId)
      Whether the commit is part of the selection.
    • selectCommit

      public void selectCommit(String id, List<String> visibleOrder, boolean toggle, boolean range)
      A click on a commit row.
      Parameters:
      visibleOrder - the ids of the rows as shown, top to bottom (for Shift-click ranges)
      toggle - Ctrl/Cmd was held: add the commit to the selection, or remove it
      range - Shift was held: select everything between the anchor and this commit
    • selectWorkingTree

      public void selectWorkingTree()
      The row of the uncommitted changes: a plain selection of it.
    • hasWipSelected

      public boolean hasWipSelected()
      Whether the working tree row is selected and has something to show.
    • addCommit

      public void addCommit(String subject, String body, List<FileChange> files, List<String> parents)
      Demo repositories only: adds a commit on the current branch.
    • createBranch

      public boolean createBranch(String name, String atId, boolean checkout)
      Returns:
      false if the branch already exists
    • merge

      public boolean merge(String name, String into, boolean deleteSource)
      Creates a merge commit of name into into (default: current branch).
    • commitWip

      public int commitWip(String summary, String description)
      Commits the staged files (or all if none is staged). @return number of committed files
    • push

      public int push()
      Moves the origin/<head> marker to the head commit. @return number of pushed commits
    • stash

      public void stash()
      Demo repositories only: puts the working tree changes on the stash.
    • discard

      public void discard()
      Demo repositories only: throws the working tree changes away.
    • popStash

      public void popStash(int index)
      Demo repositories only: brings a stash back into the working tree.
    • tag

      public void tag(String name, String atId)
      Demo repositories only: tags a commit.
    • toggleStaged

      public void toggleStaged(String path)
      Demo repositories only: stages or unstages a file.
    • setAllStaged

      public void setAllStaged(boolean staged)
      Stages every file of the working tree, or unstages them all.
    • setStaged

      public void setStaged(Collection<String> paths, boolean staged)
      Stages or unstages these files.
    • selectFile

      public void selectFile(String path, List<String> order, boolean toggle, boolean range)
      A click on a file of the working tree list.
      Parameters:
      order - the paths as listed, top to bottom (for Shift-click ranges)
      toggle - Ctrl/Cmd was held: add the file to the selection, or remove it
      range - Shift was held: select everything between the anchor and this file
    • selectedFiles

      public List<FileChange> selectedFiles()
      The selected files that are in the working tree list, in the order of the list.