Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
provider-gitlab
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
go-semantic-release
provider-gitlab
Commits
a68e7e13
Commit
a68e7e13
authored
2 years ago
by
Christoph Witzko
Browse files
Options
Downloads
Patches
Plain Diff
fix: correctly get owner/repo information and list initial commits
parent
1357f6fe
Branches
Branches containing commit
Tags
v1.12.1
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/provider/gitlab.go
+13
-4
13 additions, 4 deletions
pkg/provider/gitlab.go
pkg/provider/gitlab_test.go
+3
-1
3 additions, 1 deletion
pkg/provider/gitlab_test.go
scripts/build-local.sh
+11
-0
11 additions, 0 deletions
scripts/build-local.sh
with
27 additions
and
5 deletions
pkg/provider/gitlab.go
+
13
−
4
View file @
a68e7e13
...
...
@@ -6,6 +6,7 @@ import (
"os"
"regexp"
"strconv"
"strings"
"time"
"github.com/Masterminds/semver/v3"
...
...
@@ -81,22 +82,30 @@ func (repo *GitLabRepository) GetInfo() (*provider.RepositoryInfo, error) {
if
err
!=
nil
{
return
nil
,
err
}
namespace
,
repoName
,
_
:=
strings
.
Cut
(
project
.
PathWithNamespace
,
"/"
)
return
&
provider
.
RepositoryInfo
{
Owner
:
""
,
Repo
:
""
,
Owner
:
namespace
,
Repo
:
repoName
,
DefaultBranch
:
project
.
DefaultBranch
,
Private
:
project
.
Visibility
==
gitlab
.
PrivateVisibility
,
},
nil
}
func
(
repo
*
GitLabRepository
)
GetCommits
(
fromSha
,
toSha
string
)
([]
*
semrel
.
RawCommit
,
error
)
{
var
refName
*
string
if
fromSha
==
""
{
refName
=
gitlab
.
String
(
toSha
)
}
else
{
// No Matter the order ofr fromSha and toSha gitlab always returns commits in reverse chronological order
refName
=
gitlab
.
String
(
fmt
.
Sprintf
(
"%s...%s"
,
fromSha
,
toSha
))
}
opts
:=
&
gitlab
.
ListCommitsOptions
{
ListOptions
:
gitlab
.
ListOptions
{
Page
:
1
,
PerPage
:
100
,
},
// No Matter the order ofr fromSha and toSha gitlab always returns commits in reverse chronological order
RefName
:
gitlab
.
String
(
fmt
.
Sprintf
(
"%s...%s"
,
fromSha
,
toSha
)),
RefName
:
refName
,
}
allCommits
:=
make
([]
*
semrel
.
RawCommit
,
0
)
...
...
This diff is collapsed.
Click to expand it.
pkg/provider/gitlab_test.go
+
3
−
1
View file @
a68e7e13
...
...
@@ -71,7 +71,7 @@ func createGitlabTag(name string) *gitlab.Tag {
var
(
gitlabProjectID
=
12324322
gitlabDefaultBranch
=
"master"
gitlabProjects
=
gitlab
.
Project
{
DefaultBranch
:
gitlabDefaultBranch
,
Visibility
:
gitlab
.
PrivateVisibility
,
ID
:
gitlabProjectID
}
gitlabProjects
=
gitlab
.
Project
{
DefaultBranch
:
gitlabDefaultBranch
,
Visibility
:
gitlab
.
PrivateVisibility
,
ID
:
gitlabProjectID
,
PathWithNamespace
:
"owner/repo"
}
gitlabCommits
=
[]
*
gitlab
.
Commit
{
createGitlabCommit
(
"abcd"
,
"feat(app): new feature"
),
createGitlabCommit
(
"dcba"
,
"Fix: bug"
),
...
...
@@ -156,6 +156,8 @@ func TestGitlabGetInfo(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
gitlabDefaultBranch
,
repoInfo
.
DefaultBranch
)
require
.
True
(
t
,
repoInfo
.
Private
)
require
.
Equal
(
t
,
"owner"
,
repoInfo
.
Owner
)
require
.
Equal
(
t
,
"repo"
,
repoInfo
.
Repo
)
}
func
TestGitlabGetCommits
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
scripts/build-local.sh
0 → 100755
+
11
−
0
View file @
a68e7e13
#!/usr/bin/env bash
set
-euo
pipefail
pluginDir
=
".semrel/
$(
go
env
GOOS
)
_
$(
go
env
GOARCH
)
/provider-gitlab/0.0.0-dev/"
[[
!
-d
"
$pluginDir
"
]]
&&
{
echo
"creating
$pluginDir
"
mkdir
-p
"
$pluginDir
"
}
go build
-o
"
$pluginDir
/provider-gitlab"
./cmd/provider-gitlab
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment