Class: Hiiro::PinnedPRManager
- Inherits:
-
Object
- Object
- Hiiro::PinnedPRManager
- Defined in:
- lib/hiiro/pinned_pr_manager.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_options(opts) ⇒ Object
- #apply_filters(prs, opts, forced: []) ⇒ Object
-
#apply_isc_code_freeze_override!(rollup, frozen) ⇒ Object
Overrides the ISC code freeze StatusContext in a raw statusCheckRollup array to reflect the actual current freeze state rather than GitHub’s cached value.
-
#batch_fetch_pr_info(prs) ⇒ Object
Accepts an array of PR records (each with ‘number’ and optionally ‘repo’/‘url’), groups them by repo, and fetches in batches per repo via GraphQL.
- #code_freeze_active? ⇒ Boolean
- #display_check_runs(pr, indent: " ") ⇒ Object
- #display_detailed(pr, idx = nil) ⇒ Object
- #display_pinned(pr, idx = nil, widths: {}, oneline: false) ⇒ Object
- #ensure_file ⇒ Object
- #fetch_assigned_prs ⇒ Object
- #fetch_current_branch_pr ⇒ Object
- #fetch_my_and_assigned_prs ⇒ Object
- #fetch_my_prs ⇒ Object
- #fetch_pr_info(pr_number, repo: nil) ⇒ Object
- #filter_active?(opts) ⇒ Boolean
-
#initialize(fs: Hiiro::Effects::Filesystem.new) ⇒ PinnedPRManager
constructor
A new instance of PinnedPRManager.
- #load_pinned ⇒ Object
- #needs_refresh?(pr, force: false) ⇒ Boolean
- #pin(pr) ⇒ Object
- #pinned?(pr_number) ⇒ Boolean
- #pr_repo(pr) ⇒ Object
- #pr_yaml_lines(prs = nil) ⇒ Object
- #refresh_all_status(prs, force: false, verbose: false) ⇒ Object
- #refresh_status(pr, force: false) ⇒ Object
- #save_pinned(prs) ⇒ Object
- #strip_ansi(str) ⇒ Object
- #unpin(pr_number) ⇒ Object
Constructor Details
#initialize(fs: Hiiro::Effects::Filesystem.new) ⇒ PinnedPRManager
Returns a new instance of PinnedPRManager.
49 50 51 52 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 49 def initialize(fs: Hiiro::Effects::Filesystem.new) @fs = fs ensure_file end |
Class Method Details
.add_resolvers(hiiro) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 9 def self.add_resolvers(hiiro) pm = new hiiro.add_resolver(:pr, -> { pinned = pm.load_pinned if pinned.empty? STDERR.puts "No tracked PRs. Use a PR number or 'h pr track' to track PRs." nil else lines = pinned.each_with_index.each_with_object({}) do |(pr, idx), h| h[pm.strip_ansi(pm.display_pinned(pr, idx, oneline: true))] = pr.number.to_s end hiiro.fuzzyfind_from_map(lines) end } ) do |ref| if (pin_value = hiiro.pins.get(ref.to_s)) pin_value else pinned = pm.load_pinned if pinned.any? { |pr| pr.number.to_s == ref.to_s } ref.to_s elsif ref.to_s =~ /^\d+$/ && ref.to_i > 0 slot = ref.to_i by_slot = pinned.find { |p| p.slot.to_i == slot } if by_slot by_slot.number.to_s elsif slot - 1 < pinned.length # Fall back to 1-based index for unslotted data pinned[slot - 1].number.to_s else ref.to_s end else ref.to_s end end end end |
Instance Method Details
#add_options(opts) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 54 def (opts) opts.flag(:red, short: 'r', desc: 'filter: failing checks') opts.flag(:green, short: 'g', desc: 'filter: passing checks') opts.flag(:conflicts, short: 'c', desc: 'filter: merge conflicts') opts.flag(:drafts, short: 'D', desc: 'filter: draft PRs') opts.flag(:pending, short: 'p', desc: 'filter: pending checks') opts.flag(:merged, short: 'm', desc: 'filter: merged PRs') opts.flag(:active, short: 'o', desc: 'filter: open (non-merged) PRs') opts.flag(:numbers, short: 'n', desc: 'output PR numbers only (no #)') opts.option(:tag, short: 't', desc: 'filter by tag (OR when multiple; AND with flag filters)', multi: true) end |
#apply_filters(prs, opts, forced: []) ⇒ Object
411 412 413 414 415 416 417 418 419 420 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 411 def apply_filters(prs, opts, forced: []) results = prs.select { |pr| pr.matches_filters?(opts, forced: forced) } tag_filter = Array(opts.respond_to?(:tag) ? opts.tag : nil).map(&:to_s).reject(&:empty?) unless tag_filter.empty? results = results.select { |pr| (Array(pr.) & tag_filter).any? } end results end |
#apply_isc_code_freeze_override!(rollup, frozen) ⇒ Object
Overrides the ISC code freeze StatusContext in a raw statusCheckRollup array to reflect the actual current freeze state rather than GitHub’s cached value.
249 250 251 252 253 254 255 256 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 249 def apply_isc_code_freeze_override!(rollup, frozen) return unless rollup.is_a?(Array) rollup.each do |ctx| next unless ctx['__typename'] == 'StatusContext' && ctx['context'] == 'ISC code freeze' ctx['state'] = frozen ? 'FAILURE' : 'SUCCESS' end end |
#batch_fetch_pr_info(prs) ⇒ Object
Accepts an array of PR records (each with ‘number’ and optionally ‘repo’/‘url’), groups them by repo, and fetches in batches per repo via GraphQL.
260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 260 def batch_fetch_pr_info(prs) return {} if prs.empty? by_repo = prs.group_by { |pr| pr_repo(pr) || 'instacart/carrot' } result = {} by_repo.each do |repo_path, repo_prs| owner, name = repo_path.split('/', 2) pr_numbers = repo_prs.map(&:number) result.merge!(fetch_batch_for_repo(owner, name, pr_numbers)) end result end |
#code_freeze_active? ⇒ Boolean
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 226 def code_freeze_active? return @code_freeze_active unless @code_freeze_active.nil? output = `isc codefreeze list 2>/dev/null`.strip return @code_freeze_active = false if output.empty? now = Time.now @code_freeze_active = output.lines.drop(1).any? do |line| parts = line.strip.split(/\s{2,}/) next false if parts.length < 2 start_time = Time.parse(parts[0]) rescue nil end_time = Time.parse(parts[1]) rescue nil next false unless start_time && end_time now >= start_time && now <= end_time end rescue @code_freeze_active = false end |
#display_check_runs(pr, indent: " ") ⇒ Object
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 496 def display_check_runs(pr, indent: " ") runs = pr.check_runs return unless runs.is_a?(Array) && runs.any? runs.each do |run| case run['__typename'] when 'CheckRun' emoji = check_run_emoji(run['conclusion'], run['status']) name = run['name'] || run['workflowName'] || '(unknown)' url = run['detailsUrl'] when 'StatusContext' emoji = status_context_emoji(run['state']) name = run['context'] || '(unknown)' url = run['targetUrl'] else emoji = '?' name = run['name'] || run['context'] || '(unknown)' url = run['detailsUrl'] || run['targetUrl'] end line = "#{indent}#{emoji} #{name}" line += "\n#{indent} #{url}" if url puts line end end |
#display_detailed(pr, idx = nil) ⇒ Object
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 422 def display_detailed(pr, idx = nil) lines = [] num = idx ? "#{idx + 1}." : "" state_str = case pr.state when 'MERGED' then 'MERGED' when 'CLOSED' then 'CLOSED' else pr.draft? ? 'DRAFT' : 'OPEN' end repo = pr_repo(pr) repo_label = (repo && repo != 'instacart/carrot') ? " [#{repo}]" : "" lines << "#{num} ##{pr.number}#{repo_label} - #{pr.title}" lines << " State: #{state_str}" lines << " Branch: #{pr.head_branch}" if pr.head_branch lines << " URL: #{pr.url}" if pr.url if pr.checks c = pr.checks check_status = if c['failed'] > 0 "FAILING (#{c['success']}/#{c['total']} passed, #{c['failed']} failed)" elsif c['pending'] > 0 "PENDING (#{c['success']}/#{c['total']} passed, #{c['pending']} pending)" else "PASSING (#{c['success']}/#{c['total']})" end lines << " Checks: #{check_status}" else lines << " Checks: (none)" end if pr.reviews r = pr.reviews review_parts = [] review_parts << "#{r['approved']} approved" if r['approved'] > 0 review_parts << "#{r['changes_requested']} requesting changes" if r['changes_requested'] > 0 review_parts << "#{r['commented']} commented" if r['commented'] > 0 if review_parts.any? lines << " Reviews: #{review_parts.join(', ')}" if r['reviewers'] && !r['reviewers'].empty? r['reviewers'].each do |, state| icon = case state when 'APPROVED' then '+' when 'CHANGES_REQUESTED' then '-' else '?' end lines << " #{icon} #{}: #{state.downcase.gsub('_', ' ')}" end end else lines << " Reviews: (none)" end else lines << " Reviews: (not fetched)" end lines << " Mergeable: #{pr.mergeable}" if pr.mergeable lines.join("\n") end |
#display_pinned(pr, idx = nil, widths: {}, oneline: false) ⇒ Object
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 328 def display_pinned(pr, idx = nil, widths: {}, oneline: false) slot_w = widths[:slot] || 1 succ_w = widths[:succ] || 1 total_w = widths[:total] || 1 as_w = widths[:as] || 1 crs_w = widths[:crs] || 1 slot_num = (pr.slot || (idx ? idx + 1 : 1)).to_s num = "#{slot_num.rjust(slot_w)}." indent = " " * (slot_w + 2) check_emoji, checks_count_str = if pr.checks c = pr.checks has_failed = c['failed'].to_i > 0 has_pending = c['pending'].to_i > 0 only_frozen = has_failed && c['failed'].to_i == c['frozen'].to_i emoji = if has_failed && has_pending only_frozen ? "⏳❄️" : "⏳❌" elsif has_failed only_frozen ? " ❄️" : " ❌" elsif has_pending "⏳ " elsif c['truncated'] " ❓" else " ✅" end succ = c['success'].to_i.to_s.rjust(succ_w) total = c['total'].to_i.to_s.rjust(total_w) [emoji, "#{succ}/#{total}"] else ["", nil] end state_label = case pr.state when 'MERGED' then 'M' when 'CLOSED' then 'X' else pr.draft? ? 'd' : 'o' end bracket_parts = [state_label, check_emoji, checks_count_str].reject { |p| p.nil? || p.empty? } state_icon = "[#{bracket_parts.join(' ')}]" r = pr.reviews || {} as = r['approved'].to_i crs = r['changes_requested'].to_i as_val = as > 0 ? as.to_s : '-' crs_val = crs > 0 ? crs.to_s : '-' as_colored = as > 0 ? "\e[30;102m#{as_val}\e[0m" : as_val crs_colored = crs > 0 ? "\e[30;103m#{crs_val}\e[0m" : crs_val as_pad = " " * [as_w - as_val.length, 0].max crs_pad = " " * [crs_w - crs_val.length, 0].max conflict_str = pr.conflicting? ? " \e[30;101mC\e[0m" : "" reviews_str = "#{as_pad}#{as_colored}a/#{crs_pad}#{crs_colored}cr#{conflict_str}" repo = pr_repo(pr) repo_label = (repo && repo != 'instacart/carrot') ? "[#{repo}] " : "" = Array(pr.) = .any? ? .map { |t| "\e[30;104m#{t}\e[0m" }.join(' ') : nil branch_str = pr.head_branch ? " \e[90m#{pr.head_branch}\e[0m" : "" title_str = "\e[1m#{pr.title}\e[0m" line1 = "#{num} ##{pr.number} #{state_icon} #{reviews_str}#{branch_str}" line2 = "#{indent}#{repo_label}#{title_str}" line3 = pr.url ? "#{indent}#{pr.url}" : nil line4 = ? "#{indent}#{}" : nil if oneline "#{line1} #{repo_label}#{title_str}#{ ? " #{}" : ""}" else [line1, line2, line3, line4].compact.join("\n") end end |
#ensure_file ⇒ Object
70 71 72 73 74 75 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 70 def ensure_file return unless Hiiro::DB.dual_write? dir = File.dirname(Hiiro::Git::Pr::PINNED_FILE) FileUtils.mkdir_p(dir) unless Dir.exist?(dir) @fs.write(Hiiro::Git::Pr::PINNED_FILE, [].to_yaml) unless File.exist?(Hiiro::Git::Pr::PINNED_FILE) end |
#fetch_assigned_prs ⇒ Object
197 198 199 200 201 202 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 197 def fetch_assigned_prs output = `gh pr list --assignee @me --state open --json number,title,headRefName,url 2>/dev/null`.strip return [] if output.empty? prs = JSON.parse(output) rescue [] prs.map { |data| Hiiro::Git::Pr.from_gh_json(data) } end |
#fetch_current_branch_pr ⇒ Object
181 182 183 184 185 186 187 188 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 181 def fetch_current_branch_pr fields = 'number,title,url,headRefName,state' output = `gh pr view --json #{fields} 2>/dev/null`.strip return nil if output.empty? Hiiro::Git::Pr.from_gh_json(JSON.parse(output)) rescue JSON::ParserError nil end |
#fetch_my_and_assigned_prs ⇒ Object
204 205 206 207 208 209 210 211 212 213 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 204 def fetch_my_and_assigned_prs = fetch_my_prs assigned_prs = fetch_assigned_prs = .map(&:number).to_set assigned_prs.each { |pr| pr.assigned = true unless .include?(pr.number) } .each { |pr| pr. = true } ( + assigned_prs).uniq(&:number) end |
#fetch_my_prs ⇒ Object
190 191 192 193 194 195 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 190 def fetch_my_prs output = `gh pr list --author @me --state open --json number,title,headRefName,url 2>/dev/null`.strip return [] if output.empty? prs = JSON.parse(output) rescue [] prs.map { |data| Hiiro::Git::Pr.from_gh_json(data) } end |
#fetch_pr_info(pr_number, repo: nil) ⇒ Object
171 172 173 174 175 176 177 178 179 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 171 def fetch_pr_info(pr_number, repo: nil) fields = 'number,title,url,headRefName,state,statusCheckRollup,reviewDecision,reviews,isDraft,mergeable' repo_flag = repo ? " --repo #{repo}" : "" output = `gh pr view #{pr_number}#{repo_flag} --json #{fields} 2>/dev/null`.strip return nil if output.empty? Hiiro::Git::Pr.from_gh_json(JSON.parse(output)) rescue JSON::ParserError nil end |
#filter_active?(opts) ⇒ Boolean
405 406 407 408 409 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 405 def filter_active?(opts) all_keys = Hiiro::Git::Pr::STATE_FILTER_KEYS + Hiiro::Git::Pr::CHECK_FILTER_KEYS all_keys.any? { |f| opts.respond_to?(f) && opts.send(f) } || (opts.respond_to?(:tag) && Array(opts.tag).any?) end |
#load_pinned ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 77 def load_pinned prs = Hiiro::PinnedPr.by_slot.all if prs.any? { |p| p.slot.nil? } next_slot = prs.map { |p| p.slot.to_i }.max.to_i prs.each do |p| next if p.slot next_slot += 1 p.update(slot: next_slot) end end prs end |
#needs_refresh?(pr, force: false) ⇒ Boolean
215 216 217 218 219 220 221 222 223 224 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 215 def needs_refresh?(pr, force: false) return true if force return true unless pr.last_checked last_check_time = Time.parse(pr.last_checked) rescue nil return true unless last_check_time # Refresh if last check was more than 2 minutes ago (Time.now - last_check_time) > 120 end |
#pin(pr) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 109 def pin(pr) pr.repo ||= Hiiro::Git::Pr.repo_from_url(pr.url) existing = Hiiro::PinnedPr.find_by_number(pr.number) if existing updates = { updated_at: Time.now.iso8601, } updates[:title] = pr.title unless pr.title.nil? updates[:state] = pr.state unless pr.state.nil? updates[:url] = pr.url unless pr.url.nil? updates[:head_ref_name] = pr.head_branch unless pr.head_branch.nil? updates[:repo] = pr.repo unless pr.repo.nil? updates[:is_draft] = pr.is_draft unless pr.is_draft.nil? updates[:mergeable] = pr.mergeable unless pr.mergeable.nil? updates[:review_decision] = pr.review_decision unless pr.review_decision.nil? updates[:check_runs_json] = Hiiro::DB::JSON.dump(pr.check_runs) unless pr.check_runs.nil? updates[:checks_json] = Hiiro::DB::JSON.dump(pr.checks) unless pr.checks.nil? updates[:reviews_json] = Hiiro::DB::JSON.dump(pr.reviews) unless pr.reviews.nil? updates[:task] = pr.task unless pr.task.nil? updates[:worktree] = pr.worktree unless pr.worktree.nil? updates[:tmux_session] = pr.tmux_session unless pr.tmux_session.nil? updates[:tags_json] = Hiiro::DB::JSON.dump(pr.) unless pr..nil? updates[:assigned] = pr.assigned unless pr.assigned.nil? updates[:authored] = pr. unless pr..nil? existing.update(updates) existing.sync_check_runs if updates.key?(:check_runs_json) else pinned = pr.is_a?(Hiiro::PinnedPr) ? pr : Hiiro::PinnedPr.from_git_pr(pr) pinned.slot = Hiiro::PinnedPr.max(:slot).to_i + 1 pinned.pinned_at = Time.now.iso8601 pinned.pinned = true pinned.save pinned.sync_check_runs end # Dual-write YAML if Hiiro::DB.dual_write? ensure_file all_prs = Hiiro::PinnedPr.by_slot.all @fs.write(Hiiro::Git::Pr::PINNED_FILE, all_prs.map(&:to_pinned_h).to_yaml) end pr end |
#pinned?(pr_number) ⇒ Boolean
167 168 169 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 167 def pinned?(pr_number) load_pinned.any? { |p| p.number.to_s == pr_number.to_s } end |
#pr_repo(pr) ⇒ Object
66 67 68 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 66 def pr_repo(pr) pr.repo || Hiiro::Git::Pr.repo_from_url(pr.url) end |
#pr_yaml_lines(prs = nil) ⇒ Object
485 486 487 488 489 490 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 485 def pr_yaml_lines(prs = nil) (prs || load_pinned).map do |pr| branch = pr.head_branch ? "[#{pr.head_branch}]" : "[##{pr.number}]" "- #{pr.number} # #{branch} #{pr.title}" end end |
#refresh_all_status(prs, force: false, verbose: false) ⇒ Object
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 274 def refresh_all_status(prs, force: false, verbose: false) prs_to_refresh = prs.select { |pr| pr.active? && needs_refresh?(pr, force: force) } if prs_to_refresh.empty? puts "All PRs recently checked (within last 2 minutes). Use -U to force update." if verbose return prs end # infos is keyed by [number, repo] to avoid collisions across repos infos = batch_fetch_pr_info(prs_to_refresh) frozen = code_freeze_active? prs_to_refresh.each do |pr| info = infos[[pr.number, pr_repo(pr) || 'instacart/carrot']] next unless info rollup = info['statusCheckRollup'] apply_isc_code_freeze_override!(rollup, frozen) pr.state = info['state'] pr.title = info['title'] pr.check_runs = rollup pr.checks = Hiiro::Git::Pr.summarize_checks(rollup, truncated: info['checksTruncated']) pr.reviews = Hiiro::Git::Pr.summarize_reviews(info['reviews']) pr.review_decision = info['reviewDecision'] pr.is_draft = info['isDraft'] pr.mergeable = info['mergeable'] pr.last_checked = Time.now.iso8601 end prs end |
#refresh_status(pr, force: false) ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 307 def refresh_status(pr, force: false) return pr unless needs_refresh?(pr, force: force) info = fetch_pr_info(pr.number, repo: pr_repo(pr)) return pr unless info rollup = info.check_runs apply_isc_code_freeze_override!(rollup, code_freeze_active?) pr.state = info.state pr.title = info.title pr.check_runs = rollup pr.checks = Hiiro::Git::Pr.summarize_checks(rollup) pr.reviews = info.reviews pr.review_decision = info.review_decision pr.is_draft = info.is_draft pr.mergeable = info.mergeable pr.last_checked = Time.now.iso8601 pr end |
#save_pinned(prs) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 90 def save_pinned(prs) Hiiro::DB.connection.transaction do Hiiro::PinnedPr.where(pinned: true).delete prs.each do |pr| pinned = pr.is_a?(Hiiro::PinnedPr) ? pr : Hiiro::PinnedPr.from_git_pr(pr) attrs = pinned.to_hash.reject { |k, _| k == :id } attrs[:pinned] = true saved = Hiiro::PinnedPr.new(attrs) saved.save saved.sync_check_runs end end # Dual-write YAML for backward compat if Hiiro::DB.dual_write? ensure_file @fs.write(Hiiro::Git::Pr::PINNED_FILE, prs.map(&:to_pinned_h).to_yaml) end end |
#strip_ansi(str) ⇒ Object
492 493 494 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 492 def strip_ansi(str) str.gsub(/\e\[[0-9;]*m/, '') end |
#unpin(pr_number) ⇒ Object
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/hiiro/pinned_pr_manager.rb', line 156 def unpin(pr_number) removed = Hiiro::PinnedPr.where(number: pr_number.to_i).delete # Dual-write YAML if Hiiro::DB.dual_write? ensure_file all_prs = Hiiro::PinnedPr.by_slot.all @fs.write(Hiiro::Git::Pr::PINNED_FILE, all_prs.map(&:to_pinned_h).to_yaml) end removed end |