|
52 | 52 | error make {msg: $"Could not read the pull request: ($response.stderr | str trim)"} |
53 | 53 | } |
54 | 54 | let pr = ($response.stdout | from json) |
| 55 | + if $pr.state != 'open' { |
| 56 | + error make {msg: 'Only open pull requests are allowed'} |
| 57 | + } |
55 | 58 | if $pr.user.login != 'renovate[bot]' { |
56 | 59 | error make {msg: 'Only pull requests opened by renovate[bot] are allowed'} |
57 | 60 | } |
@@ -121,13 +124,18 @@ jobs: |
121 | 124 | } |
122 | 125 | print --stderr ($generation.stdout | str trim) |
123 | 126 |
|
124 | | - let changed = (^git diff --name-only | lines | where {|path| not ($path | is-empty)}) |
| 127 | + let status = (^git status --porcelain=v1 --untracked-files=all | lines | where {|line| not ($line | is-empty)}) |
| 128 | + let changed = ($status | each {|line| $line | str substring 3..}) |
125 | 129 | let unexpected = ($changed | where {|path| $path !~ '^nix/tools/[^/]+/bun[.]nix$'}) |
126 | 130 | if not ($unexpected | is-empty) { |
127 | 131 | error make {msg: $"The trusted generator changed unexpected files: ($unexpected | str join ', ')"} |
128 | 132 | } |
129 | 133 |
|
130 | | - let patch = (^git diff --binary --full-index -- 'nix/tools/*/bun.nix' | complete) |
| 134 | + let stage = (^git add -- ':(glob)nix/tools/*/bun.nix' | complete) |
| 135 | + if $stage.exit_code != 0 { |
| 136 | + error make {msg: $"Could not stage the generated Bun derivations: ($stage.stderr | str trim)"} |
| 137 | + } |
| 138 | + let patch = (^git diff --cached --binary --full-index -- ':(glob)nix/tools/*/bun.nix' | complete) |
131 | 139 | if $patch.exit_code != 0 { |
132 | 140 | error make {msg: $"Could not create the Bun derivation patch: ($patch.stderr | str trim)"} |
133 | 141 | } |
@@ -207,7 +215,8 @@ jobs: |
207 | 215 | if $commit.exit_code != 0 { |
208 | 216 | error make {msg: $"Could not commit generated Bun derivations: ($commit.stderr | str trim)"} |
209 | 217 | } |
210 | | - let push = (^git push origin $"HEAD:refs/heads/($env.HEAD_REF)" | complete) |
| 218 | + let lease = $"--force-with-lease=refs/heads/($env.HEAD_REF):($env.EXPECTED_HEAD_SHA)" |
| 219 | + let push = (^git push $lease origin $"HEAD:refs/heads/($env.HEAD_REF)" | complete) |
211 | 220 | if $push.exit_code != 0 { |
212 | 221 | error make {msg: $"Could not push generated Bun derivations: ($push.stderr | str trim)"} |
213 | 222 | } |
0 commit comments