|
| 1 | +# 'branch submit' gracefully handles the case |
| 2 | +# where a PR being updated is already closed. |
| 3 | +# |
| 4 | +# https://github.com/abhinav/git-spice/issues/374 |
| 5 | + |
| 6 | + |
| 7 | +at '2024-09-04T05:06:07Z' |
| 8 | + |
| 9 | +# setup |
| 10 | +cd repo |
| 11 | +git init |
| 12 | +git commit --allow-empty -m 'Initial commit' |
| 13 | + |
| 14 | +# set up a fake GitHub remote |
| 15 | +shamhub init |
| 16 | +shamhub new origin alice/example.git |
| 17 | +shamhub register alice |
| 18 | +git push origin main |
| 19 | + |
| 20 | +env SHAMHUB_USERNAME=alice |
| 21 | +gs auth login |
| 22 | + |
| 23 | +git add feat1.txt |
| 24 | +gs bc -m feat1 |
| 25 | +gs bs -c |
| 26 | +stderr 'Created #' |
| 27 | + |
| 28 | +gs ll -a |
| 29 | +cmp stderr $WORK/golden/open.txt |
| 30 | + |
| 31 | +# Close the PR |
| 32 | +shamhub reject alice/example.git 1 |
| 33 | + |
| 34 | +mv $WORK/extra/feat1-new.txt feat1.txt |
| 35 | +git add feat1.txt |
| 36 | +gs cc -m 'Update feature 1' |
| 37 | + |
| 38 | +gs branch submit --fill |
| 39 | +stderr 'Ignoring CR #1 as it was closed' |
| 40 | + |
| 41 | +gs ll -a |
| 42 | +cmp stderr $WORK/golden/resubmit.txt |
| 43 | + |
| 44 | +shamhub dump changes |
| 45 | +cmpenvJSON stdout $WORK/golden/changes.json |
| 46 | + |
| 47 | +-- repo/feat1.txt -- |
| 48 | +Contents of feature 1 |
| 49 | + |
| 50 | +-- extra/feat1-new.txt -- |
| 51 | +New contents of feature 1 |
| 52 | + |
| 53 | +-- golden/open.txt -- |
| 54 | +┏━■ feat1 (#1) ◀ |
| 55 | +┃ fabf34f feat1 (now) |
| 56 | +main |
| 57 | +-- golden/resubmit.txt -- |
| 58 | +┏━■ feat1 (#2) ◀ |
| 59 | +┃ 03fced6 Update feature 1 (now) |
| 60 | +┃ fabf34f feat1 (now) |
| 61 | +main |
| 62 | +-- golden/changes.json -- |
| 63 | +[ |
| 64 | + { |
| 65 | + "number": 1, |
| 66 | + "html_url": "$SHAMHUB_URL/alice/example/change/1", |
| 67 | + "state": "closed", |
| 68 | + "title": "feat1", |
| 69 | + "body": "", |
| 70 | + "base": { |
| 71 | + "ref": "main", |
| 72 | + "sha": "c649f748239dea65932c853775c6121d7cc79029" |
| 73 | + }, |
| 74 | + "head": { |
| 75 | + "ref": "feat1", |
| 76 | + "sha": "03fced68a13af09f59f08474c47452dd15f3042c" |
| 77 | + } |
| 78 | + }, |
| 79 | + { |
| 80 | + "number": 2, |
| 81 | + "html_url": "$SHAMHUB_URL/alice/example/change/2", |
| 82 | + "state": "open", |
| 83 | + "title": "feat1", |
| 84 | + "body": "feat1\n\nUpdate feature 1", |
| 85 | + "base": { |
| 86 | + "ref": "main", |
| 87 | + "sha": "c649f748239dea65932c853775c6121d7cc79029" |
| 88 | + }, |
| 89 | + "head": { |
| 90 | + "ref": "feat1", |
| 91 | + "sha": "03fced68a13af09f59f08474c47452dd15f3042c" |
| 92 | + } |
| 93 | + } |
| 94 | +] |
0 commit comments