Class: Agentilda::Resync::Prs
- Inherits:
-
Object
- Object
- Agentilda::Resync::Prs
- Defined in:
- lib/agentilda/resync.rb
Overview
resync prs — puts an [NNN.MM] prefix on every pull request title that
lacks one, and [DEV.00] on the ones that implement no plan.
The resolution order is the branch name first, then the diff, and only
when the diff touches exactly one plan. Anything else is reported for a
human and never edited: pull-requests.md is generated from these
titles, and a wrong number files work under a plan that did not do it,
leaving the plan that did looking untouched.
Defined Under Namespace
Classes: Change
Constant Summary collapse
- STALE =
The marker this tool used to write, now replaced. A title wearing it is rewritten in place: the assertion it makes — "this belongs to no specification" — is still true and still somebody's deliberate call, so it is restamped rather than re-resolved.
/\A\[#{Regexp.escape(Agentilda::STALE_NO_PLAN_PREFIX)}\]\s*/- PREFIXED =
Titles that already carry a prefix — a plan number, the no-plan marker, or the legacy
[XXX]. /\A\[(?:\d{3}(?:\.\d{2})?|#{Agentilda::NO_PLAN_PREFIX}|XXX)\](?:\([A-Z]\))?\s/- BRANCH_PATTERN =
Finds a plan number in a branch name:
kig/018.01-verify,002-slug. %r{(?:\A|[/\-_])(\d{3}(?:\.\d{2})?)(?:\z|[-_])}
Instance Attribute Summary collapse
- #github ⇒ Agentilda::GitHub readonly
- #tree ⇒ Agentilda::Tree readonly
Instance Method Summary collapse
- #adopt? ⇒ Boolean
-
#adoption ⇒ Array<Agentilda::Adoption>
The adopter, memoized.
-
#call(commit: false) ⇒ Array<Agentilda::Resync::Prs::Change>
What was proposed.
-
#initialize(tree:, github: GitHub.new, adopt: true, root: nil) ⇒ Prs
constructor
A new instance of Prs.
-
#plan ⇒ Array<Agentilda::Resync::Prs::Change>
What would change, without changing anything.
- #restamps ⇒ Array<Agentilda::Resync::Prs::Change>
Constructor Details
Instance Attribute Details
#github ⇒ Agentilda::GitHub (readonly)
198 199 200 |
# File 'lib/agentilda/resync.rb', line 198 def github @github end |
#tree ⇒ Agentilda::Tree (readonly)
195 196 197 |
# File 'lib/agentilda/resync.rb', line 195 def tree @tree end |
Instance Method Details
#adopt? ⇒ Boolean
192 |
# File 'lib/agentilda/resync.rb', line 192 def adopt? = @adopt |
#adoption ⇒ Array<Agentilda::Adoption>
Returns the adopter, memoized.
224 |
# File 'lib/agentilda/resync.rb', line 224 def adoption = @adoption ||= Adoption.new(tree:, github:, root: @root) |
#call(commit: false) ⇒ Array<Agentilda::Resync::Prs::Change>
Returns what was proposed.
212 213 214 215 216 217 218 219 220 221 |
# File 'lib/agentilda/resync.rb', line 212 def call(commit: false) changes = resolve(candidates) return restamps + (adopt? ? (changes) : changes) unless commit changes = (changes, create: true) if adopt? changes = restamps + changes applicable = changes.select(&:applicable?) UI.stepping(applicable, "Retitling") { |c| github.retitle(number: c.number, title: c.new_title) } changes end |
#plan ⇒ Array<Agentilda::Resync::Prs::Change>
What would change, without changing anything.
203 204 205 |
# File 'lib/agentilda/resync.rb', line 203 def plan restamps + resolve(candidates).then { |changes| adopt? ? (changes) : changes } end |
#restamps ⇒ Array<Agentilda::Resync::Prs::Change>
208 |
# File 'lib/agentilda/resync.rb', line 208 def restamps = stale.map { |pull| restamped(pull) } |