Class LabelService

java.lang.Object
io.github.jbastgen.stemma.app.label.LabelService

public final class LabelService extends Object
The commit labels for the views: knows whether the feature is on, where the index file is (it follows the settings), and gives the labels of commits. Failures to read or write the shared file never reach the views as exceptions: they are logged and reported to the user once per operation by the caller.
  • Constructor Details

    • LabelService

      public LabelService(Supplier<AppSettings> settings, Path defaultFile, Clock clock)
      Parameters:
      settings - the current settings, asked for every operation
      defaultFile - the index file when the settings name none
      clock - the time of an event
  • Method Details

    • defaultFile

      public static Path defaultFile()
      labels.tsv in the configuration folder.
    • enabled

      public boolean enabled()
      Whether commit labels are switched on.
    • file

      public Path file()
      The index file in use.
    • labels

      public List<LabelIndex.LabelDef> labels()
      The labels that exist, in order. The default ones are written to a new index first.
    • label

      public Optional<LabelIndex.LabelDef> label(String id)
      The label with this id.
    • labelsOf

      public List<LabelIndex.LabelDef> labelsOf(String repoKey, String commitId)
      The labels of a commit, in the order of the definitions.
    • commitsWithLabel

      public Set<String> commitsWithLabel(String repoKey, String text)
      Commits of a repository that have a label whose id or name matches text (case-insensitive).
    • setLabels

      public void setLabels(String repoKey, String commitId, Set<String> wanted) throws IOException
      Makes the labels of a commit exactly wanted (label ids).
      Throws:
      IOException
    • define

      public void define(LabelIndex.LabelDef def) throws IOException
      Defines a label or changes its name or colour.
      Throws:
      IOException
    • delete

      public void delete(String id) throws IOException
      Deletes a label for everyone.
      Throws:
      IOException
    • compact

      public int[] compact() throws IOException
      Rewrites the file without the events that no longer matter; returns the numbers before and after.
      Throws:
      IOException
    • importFrom

      public int importFrom(Path other) throws IOException
      Takes the labels of another file over; returns how many events were new.
      Throws:
      IOException