Skip to content

Commit b318186

Browse files
committed
try std and raw std decoding for gitlab contents
1 parent 56b21de commit b318186

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.4.0]
8+
### Added
9+
10+
- Fix issues base64 decoding GitLab content, from [@bradrydzewski](https://github.com/bradrydzewski).
11+
712
## [1.3.0]
813
### Added
914

scm/driver/gitlab/content.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ func (s *contentService) Find(ctx context.Context, repo, path, ref string) (*scm
2424
endpoint := fmt.Sprintf("api/v4/projects/%s/repository/files/%s?ref=%s", encode(repo), path, ref)
2525
out := new(content)
2626
res, err := s.client.do(ctx, "GET", endpoint, nil, out)
27-
raw, _ := base64.RawStdEncoding.DecodeString(out.Content)
27+
raw, berr := base64.StdEncoding.DecodeString(out.Content)
28+
if berr != nil {
29+
// samples in the gitlab documentation use RawStdEncoding
30+
// so we fallback if StdEncoding returns an error.
31+
raw, berr = base64.RawStdEncoding.DecodeString(out.Content)
32+
if berr != nil {
33+
return nil, res, err
34+
}
35+
}
2836
return &scm.Content{
2937
Path: out.FilePath,
3038
Data: raw,

0 commit comments

Comments
 (0)