MCPcopy Create free account
hub / github.com/FastLED/FastLED / remove_pull_request_if_needed

Function remove_pull_request_if_needed

ci/tools/gh/limit_agent_pr_workflows.py:115–135  ·  view source on GitHub ↗
(path: Path, allow_pr: bool)

Source from the content-addressed store, hash-verified

113
114
115def remove_pull_request_if_needed(path: Path, allow_pr: bool) -> WorkflowResult:
116 original_text = path.read_text(encoding="utf-8")
117 if allow_pr:
118 return WorkflowResult(path, (), original_text, original_text)
119
120 lines = original_text.splitlines(keepends=True)
121 on_block = find_on_block(lines)
122 if on_block is None:
123 return WorkflowResult(path, (), original_text, original_text)
124
125 pull_request = on_block.events.get("pull_request")
126 if pull_request is None:
127 return WorkflowResult(path, (), original_text, original_text)
128
129 updated_lines = lines[: pull_request.start] + lines[pull_request.end :]
130 return WorkflowResult(
131 path=path,
132 changes=("remove pull_request",),
133 original_text=original_text,
134 updated_text="".join(updated_lines),
135 )
136
137
138def workflow_files(workflows_dir: Path) -> list[Path]:

Callers 1

mainFunction · 0.85

Calls 3

WorkflowResultClass · 0.85
find_on_blockFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected