Skip to content

Commit 15dba7b

Browse files
authored
Merge pull request #620 from SergioChan/fix/issue-619-pr-target-checkout
ci: checkout PR head on pull_request_target runs
2 parents ec92f44 + 40ff3b0 commit 15dba7b

2 files changed

Lines changed: 37 additions & 10 deletions

File tree

.github/workflows/codetests.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ jobs:
1212
os: [ubuntu, macos, windows]
1313
runs-on: ${{ matrix.os }}-latest
1414
steps:
15-
- uses: actions/checkout@v6
15+
- name: checkout PR head (pull_request_target)
16+
if: github.event_name == 'pull_request_target'
17+
uses: actions/checkout@v6
18+
with:
19+
repository: ${{ github.event.pull_request.head.repo.full_name }}
20+
ref: ${{ github.event.pull_request.head.sha }}
21+
- name: checkout branch (push)
22+
if: github.event_name == 'push'
23+
uses: actions/checkout@v6
1624
- uses: actions/setup-go@v6
1725
with:
1826
go-version: 'stable'
@@ -32,7 +40,15 @@ jobs:
3240
env:
3341
GOOS: ${{ matrix.os }}
3442
steps:
35-
- uses: actions/checkout@v6
43+
- name: checkout PR head (pull_request_target)
44+
if: github.event_name == 'pull_request_target'
45+
uses: actions/checkout@v6
46+
with:
47+
repository: ${{ github.event.pull_request.head.repo.full_name }}
48+
ref: ${{ github.event.pull_request.head.sha }}
49+
- name: checkout branch (push)
50+
if: github.event_name == 'push'
51+
uses: actions/checkout@v6
3652
- uses: actions/setup-go@v6
3753
with:
3854
go-version: 'stable'
@@ -53,7 +69,15 @@ jobs:
5369
env:
5470
GOOS: ${{ matrix.os }}
5571
steps:
56-
- uses: actions/checkout@v6
72+
- name: checkout PR head (pull_request_target)
73+
if: github.event_name == 'pull_request_target'
74+
uses: actions/checkout@v6
75+
with:
76+
repository: ${{ github.event.pull_request.head.repo.full_name }}
77+
ref: ${{ github.event.pull_request.head.sha }}
78+
- name: checkout branch (push)
79+
if: github.event_name == 'push'
80+
uses: actions/checkout@v6
5781
- uses: actions/setup-go@v6
5882
with:
5983
go-version: 'stable'

pkg/ui/dlgs.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ func Warning(title, msg string) (bool, error) {
2727
}
2828

2929
// Error wraps an error dialog.
30-
func Error(title, msg string, v ...any) (bool, error) {
30+
func Error(title, msg string, args ...any) (bool, error) {
3131
if !HasGUI() {
3232
return true, nil
3333
}
3434

35-
return dialogResult(zenity.Error(fmt.Sprintf(msg, v...), zenity.Title(title)))
35+
return dialogResult(zenity.Error(fmt.Sprintf(msg, args...), zenity.Title(title)))
3636
}
3737

3838
// Info wraps an info dialog.
39-
func Info(title, msg string, v ...any) (bool, error) {
39+
func Info(title, msg string, args ...any) (bool, error) {
4040
if !HasGUI() {
4141
return true, nil
4242
}
4343

44-
return dialogResult(zenity.Info(fmt.Sprintf(msg, v...), zenity.Title(title)))
44+
return dialogResult(zenity.Info(fmt.Sprintf(msg, args...), zenity.Title(title)))
4545
}
4646

4747
// Entry wraps a text-entry dialog.
@@ -54,12 +54,15 @@ func Entry(title, msg, val string) (string, bool, error) {
5454
if errors.Is(err, zenity.ErrCanceled) {
5555
return val, false, nil
5656
}
57+
if err != nil {
58+
return entry, false, fmt.Errorf("zenity entry: %w", err)
59+
}
5760

58-
return entry, err == nil, err
61+
return entry, true, nil
5962
}
6063

6164
// Question wraps a question dialog.
62-
func Question(title string, defaultCancel bool, text string, v ...any) (bool, error) {
65+
func Question(title string, defaultCancel bool, text string, args ...any) (bool, error) {
6366
if !HasGUI() {
6467
return true, nil
6568
}
@@ -69,5 +72,5 @@ func Question(title string, defaultCancel bool, text string, v ...any) (bool, er
6972
opts = append(opts, zenity.DefaultCancel())
7073
}
7174

72-
return dialogResult(zenity.Question(fmt.Sprintf(text, v...), opts...))
75+
return dialogResult(zenity.Question(fmt.Sprintf(text, args...), opts...))
7376
}

0 commit comments

Comments
 (0)