@@ -2,7 +2,6 @@ package provider
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"fmt"
7
6
"os"
8
7
"regexp"
@@ -22,21 +21,30 @@ type GiteaRepository struct {
22
21
repo string
23
22
owner string
24
23
stripVTagPrefix bool
25
- compareCommits bool
26
24
baseURL string
27
25
}
28
26
29
- //gocyclo:ignore
27
+ // gocyclo:ignore
30
28
func (repo * GiteaRepository ) Init (config map [string ]string ) error {
31
29
giteaHost := config ["gitea_host" ]
32
30
if giteaHost == "" {
33
31
giteaHost = os .Getenv ("GITEA_HOST" )
34
32
}
33
+ // If host is still not set error
34
+ if giteaHost == "" {
35
+ return fmt .Errorf ("gitea host is not set" )
36
+ }
37
+
35
38
repo .baseURL = giteaHost
36
39
slug := config ["slug" ]
40
+
37
41
if slug == "" {
38
42
slug = os .Getenv ("GITHUB_REPOSITORY" )
39
43
}
44
+ // Maybe we are running in Gitea Actions
45
+ if slug == "" {
46
+ slug = os .Getenv ("GITEA_REPOSITORY" )
47
+ }
40
48
// Maybe we are running in WoodpeckerCI
41
49
if slug == "" {
42
50
slug = os .Getenv ("CI_REPO_NAME" )
@@ -47,11 +55,11 @@ func (repo *GiteaRepository) Init(config map[string]string) error {
47
55
token = os .Getenv ("GITEA_TOKEN" )
48
56
}
49
57
if token == "" {
50
- return errors . New ("gitea token missing" )
58
+ return fmt . Errorf ("gitea token missing" )
51
59
}
52
60
53
61
if ! strings .Contains (slug , "/" ) {
54
- return errors . New ("invalid slug" )
62
+ return fmt . Errorf ("invalid slug" )
55
63
}
56
64
split := strings .Split (slug , "/" )
57
65
// This could be due to act locally
@@ -63,21 +71,16 @@ func (repo *GiteaRepository) Init(config map[string]string) error {
63
71
repo .repo = strings .TrimSuffix (repo .repo , ".git" )
64
72
65
73
ctx := context .Background ()
66
- if giteaHost != "" {
67
- client , err := gitea .NewClient (giteaHost ,
68
- gitea .SetToken (token ),
69
- gitea .SetContext (ctx ))
70
- if err != nil {
71
- return err
72
- }
73
- repo .client = client
74
- }
75
74
76
- if config ["github_use_compare_commits" ] == "true" {
77
- repo .compareCommits = true
75
+ client , err := gitea .NewClient (giteaHost ,
76
+ gitea .SetToken (token ),
77
+ gitea .SetContext (ctx ))
78
+ if err != nil {
79
+ return err
78
80
}
79
81
80
- var err error
82
+ repo .client = client
83
+
81
84
stripVTagPrefix := config ["strip_v_tag_prefix" ]
82
85
repo .stripVTagPrefix , err = strconv .ParseBool (stripVTagPrefix )
83
86
@@ -101,15 +104,6 @@ func (repo *GiteaRepository) GetInfo() (*provider.RepositoryInfo, error) {
101
104
}, nil
102
105
}
103
106
104
- //lint:ignore U1000 Ignore unused function temporarily for debugging
105
- //revive:disable-next-line
106
- func (repo * GiteaRepository ) getCommitsFromGitea (fromSha string , opts * gitea.ListOptions ) ([]* gitea.Commit , * gitea.Response , error ) {
107
- return repo .client .ListRepoCommits (repo .owner , repo .repo , gitea.ListCommitOptions {
108
- SHA : fromSha ,
109
- ListOptions : * opts ,
110
- })
111
- }
112
-
113
107
func (repo * GiteaRepository ) GetCommits (_ , toSha string ) ([]* semrel.RawCommit , error ) {
114
108
allCommits := make ([]* semrel.RawCommit , 0 )
115
109
opts := & gitea.ListOptions {PageSize : 100 }
0 commit comments