Skip to content

Commit ecb13db

Browse files
committed
chore: reorder import
1 parent 56c8c99 commit ecb13db

14 files changed

+52
-38
lines changed

command.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package caddy_webhook
22

33
import (
4-
"go.uber.org/zap"
54
"os/exec"
5+
6+
"go.uber.org/zap"
67
)
78

89
type Cmd struct {

repository.go

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package caddy_webhook
33
import (
44
"context"
55
"fmt"
6+
67
"github.com/go-git/go-git/v5"
78
"github.com/go-git/go-git/v5/config"
89
"github.com/go-git/go-git/v5/plumbing"

webhook.go

+21-20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ package caddy_webhook
33
import (
44
"context"
55
"fmt"
6+
"io"
7+
"net/http"
8+
"net/url"
9+
"os"
10+
"path/filepath"
11+
"strconv"
12+
"strings"
13+
614
"github.com/WingLim/caddy-webhook/webhooks"
715
"github.com/caddyserver/caddy/v2"
816
"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
@@ -12,13 +20,6 @@ import (
1220
githttp "github.com/go-git/go-git/v5/plumbing/transport/http"
1321
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
1422
"go.uber.org/zap"
15-
"io"
16-
"net/http"
17-
"net/url"
18-
"os"
19-
"path/filepath"
20-
"strconv"
21-
"strings"
2223
)
2324

2425
// Interface guards.
@@ -37,47 +38,47 @@ func init() {
3738
// WebHook is the module configuration.
3839
type WebHook struct {
3940
// Git repository URL, supported http, https and ssh.
40-
Repository string `json:"repo,omitempty"`
41+
Repository string `json:"repo,omitempty"`
4142

4243
// Path to clone and update repository.
43-
Path string `json:"path,omitempty"`
44+
Path string `json:"path,omitempty"`
4445

4546
// Branch to pull.
4647
// Default to `main`.
47-
Branch string `json:"branch,omitempty"`
48+
Branch string `json:"branch,omitempty"`
4849

4950
// Webhook type.
5051
// Default to `github`.
51-
Type string `json:"type,omitempty"`
52+
Type string `json:"type,omitempty"`
5253

5354
// Secret to verify webhook request.
54-
Secret string `json:"secret,omitempty"`
55+
Secret string `json:"secret,omitempty"`
5556

5657
// Depth for pull and fetch.
5758
// Default to `0`.
58-
Depth string `json:"depth,omitempty"`
59+
Depth string `json:"depth,omitempty"`
5960

6061
// Enable recurse submodules.
61-
Submodule bool `json:"submodule,omitempty"`
62+
Submodule bool `json:"submodule,omitempty"`
6263

6364
// Command to run when repo initializes or receive a
6465
// correct webhook request.
65-
Command []string `json:"command,omitempty"`
66+
Command []string `json:"command,omitempty"`
6667

6768
// Path of private key, using to access git with ssh.
68-
Key string `json:"key,omitempty"`
69+
Key string `json:"key,omitempty"`
6970

7071
// Password of private key.
71-
KeyPassword string `json:"key_password,omitempty"`
72+
KeyPassword string `json:"key_password,omitempty"`
7273

7374
// Username for http auth.
74-
Username string `json:"username,omitempty"`
75+
Username string `json:"username,omitempty"`
7576

7677
// Password for http auth.
77-
Password string `json:"password,omitempty"`
78+
Password string `json:"password,omitempty"`
7879

7980
// GitHub personal access token.
80-
Token string `json:"token,omitempty"`
81+
Token string `json:"token,omitempty"`
8182

8283
hook webhooks.HookService
8384
auth transport.AuthMethod

webhook_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package caddy_webhook
22

33
import (
44
"fmt"
5-
"github.com/alecthomas/assert"
6-
"github.com/go-git/go-git/v5"
75
"os"
86
"testing"
7+
8+
"github.com/alecthomas/assert"
9+
"github.com/go-git/go-git/v5"
910
)
1011

1112
func TestGetRepoNameFromURL(t *testing.T) {

webhooks/bitbucket_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package webhooks
33
import (
44
"bytes"
55
"fmt"
6-
"github.com/alecthomas/assert"
7-
"github.com/go-git/go-git/v5/plumbing"
86
"net/http"
97
"testing"
108
"time"
9+
10+
"github.com/alecthomas/assert"
11+
"github.com/go-git/go-git/v5/plumbing"
1112
)
1213

1314
func TestBitbucketHandle(t *testing.T) {

webhooks/gitee.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package webhooks
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/go-git/go-git/v5/plumbing"
76
"io/ioutil"
87
"net/http"
8+
9+
"github.com/go-git/go-git/v5/plumbing"
910
)
1011

1112
type Gitee struct {

webhooks/gitee_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package webhooks
33
import (
44
"bytes"
55
"fmt"
6-
"github.com/alecthomas/assert"
7-
"github.com/go-git/go-git/v5/plumbing"
86
"net/http"
97
"testing"
8+
9+
"github.com/alecthomas/assert"
10+
"github.com/go-git/go-git/v5/plumbing"
1011
)
1112

1213
func TestGiteeHandle(t *testing.T) {

webhooks/github.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"encoding/hex"
77
"encoding/json"
88
"fmt"
9-
"github.com/go-git/go-git/v5/plumbing"
109
"io/ioutil"
1110
"net/http"
11+
12+
"github.com/go-git/go-git/v5/plumbing"
1213
)
1314

1415
type Github struct {

webhooks/github_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package webhooks
33
import (
44
"bytes"
55
"fmt"
6-
"github.com/alecthomas/assert"
7-
"github.com/go-git/go-git/v5/plumbing"
86
"net/http"
97
"testing"
8+
9+
"github.com/alecthomas/assert"
10+
"github.com/go-git/go-git/v5/plumbing"
1011
)
1112

1213
func TestGithubHandle(t *testing.T) {

webhooks/gitlab.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package webhooks
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/go-git/go-git/v5/plumbing"
76
"io/ioutil"
87
"net/http"
8+
9+
"github.com/go-git/go-git/v5/plumbing"
910
)
1011

1112
type Gitlab struct {

webhooks/gitlab_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package webhooks
33
import (
44
"bytes"
55
"fmt"
6-
"github.com/alecthomas/assert"
7-
"github.com/go-git/go-git/v5/plumbing"
86
"net/http"
97
"testing"
8+
9+
"github.com/alecthomas/assert"
10+
"github.com/go-git/go-git/v5/plumbing"
1011
)
1112

1213
func TestGitlabHandle(t *testing.T) {

webhooks/gogs.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"encoding/hex"
77
"encoding/json"
88
"fmt"
9-
"github.com/go-git/go-git/v5/plumbing"
109
"io/ioutil"
1110
"net/http"
11+
12+
"github.com/go-git/go-git/v5/plumbing"
1213
)
1314

1415
type Gogs struct {

webhooks/gogs_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package webhooks
33
import (
44
"bytes"
55
"fmt"
6-
"github.com/alecthomas/assert"
7-
"github.com/go-git/go-git/v5/plumbing"
86
"net/http"
97
"testing"
8+
9+
"github.com/alecthomas/assert"
10+
"github.com/go-git/go-git/v5/plumbing"
1011
)
1112

1213
func TestGogsHandle(t *testing.T) {

webhooks/hookservice.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package webhooks
22

33
import (
4-
"github.com/go-git/go-git/v5/plumbing"
54
"net/http"
5+
6+
"github.com/go-git/go-git/v5/plumbing"
67
)
78

89
type HookConf struct {

0 commit comments

Comments
 (0)