Skip to content

core: one way to select tracked pages #48

Closed

Description

@CameronBrooks11

Push and Diff each pick tracked pages and sort them with their own copy of the code, and their nil checks are opposite (push.go: titles != nil means "these"; diff.go: titles == nil means "all"). In both, a non-nil empty slice selects nothing, so main works around it twice:

var selected []string
if titles := fs.Args(); len(titles) > 0 {
	selected = titles
}

Related duplication:

  • cmdDiff has its own inline copy of reportUntracked.
  • Status, Diff and isClean call fileExists and then os.ReadFile, which stats the file twice. ReadFile plus errors.Is(err, fs.ErrNotExist) covers both.

Fix: one manifest method returns the tracked titles in order, with no names meaning all. Push, Diff and both commands use it, and cmdDiff uses reportUntracked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions