Class WorkingSetResolver

java.lang.Object
network.ike.workspace.WorkingSetResolver

public final class WorkingSetResolver extends Object
Resolves the WorkingSet a working-tree operation acts on, from a starting directory (IKE-Network/ike-issues#609, under #601).

Searches upward from the start directory for a manifest — "working-set.yaml", or "workspace.yaml" in a working set the scaffold has not upgraded yet (ike-issues#1054). When one is found, the working set is what it declares: its subprojects plus the working-set root. When none is found, the working set is the single repository at the start directory: a working set of one.

This is the single home for the "am I in a declared working set, or a lone repo?" decision that working-tree goals otherwise each make for themselves — the scattered isWorkspaceMode() + bare-mode branches the migration in ike-issues#611 retires.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The manifest's former name.
    static final String
    The manifest file name — the thing it describes is a working set, so that is what the file is called (IKE-Network/ike-issues#1054).
  • Method Summary

    Modifier and Type
    Method
    Description
    static Path
    The manifest already present in a directory — the current name preferred, the former name accepted.
    static Path
    Where a writer should write a directory's manifest: the file that is already there, or the current name when there is none.
    static WorkingSet
    resolve(Path startDir)
    Resolve the working set from a starting directory.
    static WorkingSet
    Build a single-repository working set rooted at dir, without searching for a manifest — a working set of one.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MANIFEST_FILE

      public static final String MANIFEST_FILE
      The manifest file name — the thing it describes is a working set, so that is what the file is called (IKE-Network/ike-issues#1054).
      See Also:
    • LEGACY_MANIFEST_FILE

      public static final String LEGACY_MANIFEST_FILE
      The manifest's former name. Read forever: manifests written before the rename live in tagged trees, and a working set is upgraded by the scaffold, not by every reader assuming it already happened.
      See Also:
  • Method Details

    • manifestIn

      public static Path manifestIn(Path dir)
      The manifest already present in a directory — the current name preferred, the former name accepted.
      Parameters:
      dir - the directory to look in
      Returns:
      the existing manifest path, or null when the directory holds neither
    • manifestToWrite

      public static Path manifestToWrite(Path dir)
      Where a writer should write a directory's manifest: the file that is already there, or the current name when there is none. A writer must never introduce a second manifest beside an existing one.
      Parameters:
      dir - the working-set root directory
      Returns:
      the path to write
    • resolve

      public static WorkingSet resolve(Path startDir)
      Resolve the working set from a starting directory.
      Parameters:
      startDir - the directory to resolve from (typically the CWD)
      Returns:
      the declared working set when a manifest is found at or above startDir; otherwise the single-repository working set rooted at startDir
    • singleRepo

      public static WorkingSet singleRepo(Path dir)
      Build a single-repository working set rooted at dir, without searching for a manifest — a working set of one.
      Parameters:
      dir - the repository directory
      Returns:
      the single-repository working set