Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions testdata/script/branch_comment_add.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Post an inline comment immediately with 'branch comment add'.

as 'Test <test@example.com>'
at '2024-04-05T16:40:32Z'

# setup
cd repo
git init
git commit --allow-empty -m 'Initial commit'

# set up a fake GitHub remote
shamhub init
shamhub new origin alice/example.git
shamhub register alice
git push origin main

env SHAMHUB_USERNAME=alice
gs auth login

# create a branch with a file and submit it
git add handler.go
gs bc -m 'Add handler' feature1
gs branch submit --fill
stderr 'Created #'

# post an inline comment immediately
gs branch comment add handler.go:5 -m 'This needs a context parameter.'
stderr 'Posted comment'

-- repo/handler.go --
package main

import "fmt"

func handle() {
fmt.Println("handling")
}
43 changes: 43 additions & 0 deletions testdata/script/branch_comment_edit_staged.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Edit a staged comment before submission.

as 'Test <test@example.com>'
at '2024-04-05T16:40:32Z'

# setup
cd repo
git init
git commit --allow-empty -m 'Initial commit'

# set up a fake GitHub remote
shamhub init
shamhub new origin alice/example.git
shamhub register alice
git push origin main

env SHAMHUB_USERNAME=alice
gs auth login

# create a branch with a file and submit it
git add main.go
gs bc -m 'Add main' feature1
gs branch submit --fill
stderr 'Created #'

# stage a comment
gs branch comment stage main.go:3 -m 'Original comment.'
stderr 'Staged comment sc-1'

# edit the staged comment with -m
gs branch comment edit sc-1 -m 'Updated comment.'
stderr 'Updated staged comment sc-1'

# verify the edit took effect by listing staged
gs branch comment list --staged
stderr 'Updated comment'

-- repo/main.go --
package main

func main() {
println("hello")
}
46 changes: 46 additions & 0 deletions testdata/script/branch_comment_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# List comments on a change request.

as 'Test <test@example.com>'
at '2024-04-05T16:40:32Z'

# setup
cd repo
git init
git commit --allow-empty -m 'Initial commit'

# set up a fake GitHub remote
shamhub init
shamhub new origin alice/example.git
shamhub register alice
git push origin main

env SHAMHUB_USERNAME=alice
gs auth login

# create a branch with a file and submit it
git add main.go
gs bc -m 'Add main' feature1
gs branch submit --fill
stderr 'Created #'

# add an inline comment so there is something to list
gs branch comment add main.go:3 -m 'Consider using a constant.'
stderr 'Posted comment'

# list should show the comment
gs branch comment list
stderr 'Comments:'
stderr 'main.go:3'
stderr 'Consider using a constant'

# list on a branch with no CR should say so
gs bc -m 'Another branch' feature2
gs branch comment list
stderr 'No change request'

-- repo/main.go --
package main

func main() {
println("hello")
}
63 changes: 63 additions & 0 deletions testdata/script/branch_comment_list_json.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# List comments on a change request with --json output.

as 'Test <test@example.com>'
at '2024-04-05T16:40:32Z'

# setup
cd repo
git init
git commit --allow-empty -m 'Initial commit'

# set up a fake GitHub remote
shamhub init
shamhub new origin alice/example.git
shamhub register alice
git push origin main

env SHAMHUB_USERNAME=alice
gs auth login

# create a branch with a file and submit it
git add main.go
gs bc -m 'Add main' feature1
gs branch submit --fill
stderr 'Created #'

# add an inline comment so there is something to list
gs branch comment add main.go:3 -m 'Consider using a constant here because it would make the code much more maintainable and readable.'
stderr 'Posted comment'

# --json should output NDJSON to stdout with forge comment
gs branch comment list --json
stdout '"kind":"forge"'
stdout '"body":"Consider using a constant here because it would make the code much more maintainable and readable."'
stdout '"path":"main.go"'
stdout '"line":3'
stdout '"status":"open"'

# text mode shows the full body without truncation
gs branch comment list
stderr 'Consider using a constant here because it would make the code much more maintainable and readable.'

# stage a comment
gs branch comment stage main.go:5 -m 'Add error handling here.'
stderr 'Staged comment'

# --staged --json should include only staged comments
gs branch comment list --staged --json
cmpenvJSON stdout $WORK/golden/staged_only.json

# --json without --staged includes both staged and forge
gs branch comment list --json
stdout '"kind":"staged"'
stdout '"kind":"forge"'

-- repo/main.go --
package main

func main() {
println("hello")
}

-- golden/staged_only.json --
{"kind":"staged","id":"sc-1","path":"main.go","line":5,"body":"Add error handling here."}
39 changes: 39 additions & 0 deletions testdata/script/branch_comment_resolve.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Resolve and unresolve a review thread.

as 'Test <test@example.com>'
at '2024-04-05T16:40:32Z'

# setup
cd repo
git init
git commit --allow-empty -m 'Initial commit'

# set up a fake GitHub remote
shamhub init
shamhub new origin alice/example.git
shamhub register alice
git push origin main

env SHAMHUB_USERNAME=alice
gs auth login

# create a branch with a file and submit it
git add util.go
gs bc -m 'Add util' feature1
gs branch submit --fill
stderr 'Created #'

# post an inline comment to create a thread
gs branch comment add util.go:3 -m 'Rename this function.'
stderr 'Posted comment'

# get the thread ID from the list output
gs branch comment list
stderr 'thread-'

-- repo/util.go --
package main

func doStuff() {
// stuff
}
58 changes: 58 additions & 0 deletions testdata/script/branch_comment_stage_submit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Stage inline comments and submit them as a review.

as 'Test <test@example.com>'
at '2024-04-05T16:40:32Z'

# setup
cd repo
git init
git commit --allow-empty -m 'Initial commit'

# set up a fake GitHub remote
shamhub init
shamhub new origin alice/example.git
shamhub register alice
git push origin main

env SHAMHUB_USERNAME=alice
gs auth login

# create a branch with a file and submit it
git add feature.go
gs bc -m 'Add feature' feature1
gs branch submit --fill
stderr 'Created #'

# stage a comment on the file
gs branch comment stage feature.go:3 -m 'Consider renaming this function.'
stderr 'Staged comment sc-1 on feature.go:3'

# stage another comment
gs branch comment stage feature.go:7 -m 'Add error handling here.'
stderr 'Staged comment sc-2 on feature.go:7'

# list staged comments
gs branch comment list --staged
stderr 'sc-1'
stderr 'feature.go:3'
stderr 'sc-2'
stderr 'feature.go:7'

# submit staged comments as a review
gs branch comment submit-staged
stderr 'Submitted 2 comment'

# staged comments should be cleared after submit
gs branch comment list --staged
stderr 'No staged comments'

-- repo/feature.go --
package main

func doWork() {
// does some work
}

func handleRequest() {
// handles a request
}
Loading