• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

charmbracelet / glow / 18684564545

21 Oct 2025 12:56PM UTC coverage: 3.387%. First build
18684564545

Pull #786

github

caarlos0
test: update

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Pull Request #786: feat: use fang

1 of 49 new or added lines in 5 files covered. (2.04%)

71 of 2096 relevant lines covered (3.39%)

0.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/gitlab.go
1
package main
2

3
import (
4
        "context"
5
        "encoding/json"
6
        "errors"
7
        "fmt"
8
        "io"
9
        "net/http"
10
        "net/url"
11
        "strings"
12
)
13

14
// findGitLabREADME tries to find the correct README filename in a repository using GitLab API.
NEW
15
func findGitLabREADME(ctx context.Context, u *url.URL) (*source, error) {
×
16
        owner, repo, ok := strings.Cut(strings.TrimPrefix(u.Path, "/"), "/")
×
17
        if !ok {
×
18
                return nil, fmt.Errorf("invalid url: %s", u.String())
×
19
        }
×
20

21
        projectPath := url.QueryEscape(owner + "/" + repo)
×
22

×
23
        type readme struct {
×
24
                ReadmeURL string `json:"readme_url"`
×
25
        }
×
26

×
27
        apiURL := fmt.Sprintf("https://%s/api/v4/projects/%s", u.Hostname(), projectPath)
×
28

×
NEW
29
        req, err := http.NewRequestWithContext(ctx, http.MethodGet, apiURL, nil)
×
NEW
30
        if err != nil {
×
NEW
31
                return nil, fmt.Errorf("unable to create request: %w", err)
×
NEW
32
        }
×
NEW
33
        res, err := http.DefaultClient.Do(req)
×
34
        if err != nil {
×
35
                return nil, fmt.Errorf("unable to get url: %w", err)
×
36
        }
×
NEW
37
        defer res.Body.Close() //nolint:errcheck
×
38

×
39
        body, err := io.ReadAll(res.Body)
×
40
        if err != nil {
×
41
                return nil, fmt.Errorf("unable to read http response body: %w", err)
×
42
        }
×
43

44
        var result readme
×
45
        if err := json.Unmarshal(body, &result); err != nil {
×
46
                return nil, fmt.Errorf("unable to parse json: %w", err)
×
47
        }
×
48

49
        readmeRawURL := strings.ReplaceAll(result.ReadmeURL, "blob", "raw")
×
50

×
51
        if res.StatusCode == http.StatusOK {
×
NEW
52
                // consumer of the source is responsible for closing the ReadCloser.
×
NEW
53
                req, err := http.NewRequestWithContext(ctx, http.MethodGet, readmeRawURL, nil)
×
NEW
54
                if err != nil {
×
NEW
55
                        return nil, fmt.Errorf("unable to create request: %w", err)
×
NEW
56
                }
×
NEW
57
                resp, err := http.DefaultClient.Do(req) //nolint:bodyclose
×
58
                if err != nil {
×
59
                        return nil, fmt.Errorf("unable to get url: %w", err)
×
60
                }
×
61

62
                if resp.StatusCode == http.StatusOK {
×
63
                        return &source{resp.Body, readmeRawURL}, nil
×
64
                }
×
65
        }
66

67
        return nil, errors.New("can't find README in GitLab repository")
×
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc