@@ -34,7 +34,7 @@ import qualified Text.Regex.PCRE.Heavy as RE
3434import Utils.Github (showGithubException )
3535import Utils.Gitlab (showGitlabException )
3636
37- data GitServer = Github | Gitlab GitlabHost
37+ data GitServer = Github | Gitlab GitlabHost | Codeberg
3838 deriving (Eq , Show )
3939
4040data IssueStatus = Open | Closed deriving (Eq , Show )
@@ -58,6 +58,7 @@ serverDomain ::
5858 GitServer ->
5959 Text
6060serverDomain Github = " github.com"
61+ serverDomain Codeberg = " codeberg.org"
6162serverDomain (Gitlab (GitlabHost h)) = h
6263
6364-- | This regex represents a github/gitlab issue URL
@@ -75,6 +76,7 @@ extractIssuesOnALine lineContent = map f (RE.scan gitRepoRe lineContent)
7576 colNo = 1 + ByteString. length (fst $ ByteString. breakSubstring match lineContent)
7677 provider
7778 | domain == " github.com" = Github
79+ | domain == " codeberg.org" = Codeberg
7880 -- TODO: We suppose that all other cases are gitlab
7981 -- The only thing we risk here is a query with the wrong
8082 -- API to an irrelevant host.
@@ -109,6 +111,7 @@ issueUrl ::
109111 Req. Url 'Req.Https
110112issueUrl issue = case server issue of
111113 Github -> Req. https " api.github.com" Req. /: " repos" Req. /: owner issue Req. /: repo issue Req. /: " issues" Req. /~ issueNum issue
114+ Codeberg -> Req. https " codeberg.org" Req. /: " api" Req. /: " v1" Req. /: " repos" Req. /: owner issue Req. /: repo issue Req. /: " issues" Req. /~ issueNum issue
112115 Gitlab (GitlabHost host) -> Req. https host Req. /: " api" Req. /: " v4" Req. /: " projects" Req. /: [fmt |{owner issue}/{repo issue}|] Req. /: " issues" Req. /~ issueNum issue
113116
114117-- try Issue can fail, on non-2xx HTTP response
@@ -129,10 +132,14 @@ headersFor ::
129132headersFor issue = do
130133 mGithubKey <- krankAsks githubKey
131134 mGitlabKeys <- krankAsks gitlabKeys
135+ mCodebergKey <- krankAsks codebergKey
132136 case server issue of
133137 Github -> case mGithubKey of
134138 Just (GithubKey token) -> pure $ Req. oAuth2Token (Text.Encoding. encodeUtf8 token)
135139 Nothing -> pure mempty
140+ Codeberg -> case mCodebergKey of
141+ Just (CodebergKey token) -> pure $ Req. oAuth2Token (Text.Encoding. encodeUtf8 token)
142+ Nothing -> pure mempty
136143 Gitlab host -> case Map. lookup host mGitlabKeys of
137144 Just (GitlabKey token) -> pure $ Req. header " PRIVATE-TOKEN" (Text.Encoding. encodeUtf8 token)
138145 Nothing -> pure mempty
@@ -150,6 +157,7 @@ showGitServerException ::
150157 Req. HttpException ->
151158 Text
152159showGitServerException Github exc = showGithubException exc
160+ showGitServerException Codeberg exc = showGithubException exc
153161showGitServerException (Gitlab _) exc = showGitlabException exc
154162
155163restIssue ::
0 commit comments