forked from git-workflow/autogits
Compare commits
6 Commits
new-packag
...
maintainer
| Author | SHA256 | Date | |
|---|---|---|---|
| f0b053ca07 | |||
| 844ec8a87b | |||
| 6ee8fcc597 | |||
| 1220799e57 | |||
| 86a176a785 | |||
| bb9e9a08e5 |
@@ -129,6 +129,9 @@ go build \
|
||||
go build \
|
||||
-C utils/hujson \
|
||||
-buildmode=pie
|
||||
go build \
|
||||
-C utils/maintainer-update \
|
||||
-buildmode=pie
|
||||
go build \
|
||||
-C gitea-events-rabbitmq-publisher \
|
||||
-buildmode=pie
|
||||
@@ -179,6 +182,7 @@ install -D -m0755 workflow-direct/workflow-direct
|
||||
install -D -m0644 systemd/workflow-direct@.service %{buildroot}%{_unitdir}/workflow-direct@.service
|
||||
install -D -m0755 workflow-pr/workflow-pr %{buildroot}%{_bindir}/workflow-pr
|
||||
install -D -m0755 utils/hujson/hujson %{buildroot}%{_bindir}/hujson
|
||||
install -D -m0755 utils/maintainer-update/maintainer-update %{buildroot}${_bindir}/maintainer-update
|
||||
|
||||
%pre gitea-events-rabbitmq-publisher
|
||||
%service_add_pre gitea-events-rabbitmq-publisher.service
|
||||
@@ -285,6 +289,7 @@ install -D -m0755 utils/hujson/hujson
|
||||
%files utils
|
||||
%license COPYING
|
||||
%{_bindir}/hujson
|
||||
%{_bindir}/maintainer-update
|
||||
|
||||
%files workflow-direct
|
||||
%license COPYING
|
||||
|
||||
@@ -65,7 +65,6 @@ const (
|
||||
Label_StagingAuto = "staging/Auto"
|
||||
Label_ReviewPending = "review/Pending"
|
||||
Label_ReviewDone = "review/Done"
|
||||
Label_NewRepository = "new/New Repository"
|
||||
)
|
||||
|
||||
func LabelKey(tag_value string) string {
|
||||
|
||||
@@ -272,11 +272,7 @@ func (e *GitHandlerImpl) GitClone(repo, branch, remoteUrl string) (string, error
|
||||
LogDebug("branch", branch)
|
||||
}
|
||||
*/
|
||||
args := []string{"fetch", "--prune", remoteName}
|
||||
if len(branch) > 0 {
|
||||
args = append(args, branch)
|
||||
}
|
||||
|
||||
args := []string{"fetch", "--prune", remoteName, branch}
|
||||
if strings.TrimSpace(e.GitExecWithOutputOrPanic(repo, "rev-parse", "--is-shallow-repository")) == "true" {
|
||||
args = slices.Insert(args, 1, "--unshallow")
|
||||
}
|
||||
|
||||
@@ -75,10 +75,6 @@ type GiteaLabelSettter interface {
|
||||
SetLabels(org, repo string, idx int64, labels []string) ([]*models.Label, error)
|
||||
}
|
||||
|
||||
type GiteaIssueFetcher interface {
|
||||
GetIssue(org, repo string, idx int64) (*models.Issue, error)
|
||||
}
|
||||
|
||||
type GiteaTimelineFetcher interface {
|
||||
GetTimeline(org, repo string, idx int64) ([]*models.TimelineComment, error)
|
||||
}
|
||||
@@ -151,7 +147,6 @@ type GiteaReviewRequester interface {
|
||||
|
||||
type GiteaReviewUnrequester interface {
|
||||
UnrequestReview(org, repo string, id int64, reviwers ...string) error
|
||||
UpdateIssue(org, repo string, idx int64, options *models.EditIssueOption) (*models.Issue, error)
|
||||
}
|
||||
|
||||
type GiteaReviewer interface {
|
||||
@@ -205,7 +200,6 @@ type Gitea interface {
|
||||
GiteaSetRepoOptions
|
||||
GiteaLabelGetter
|
||||
GiteaLabelSettter
|
||||
GiteaIssueFetcher
|
||||
|
||||
GetNotifications(Type string, since *time.Time) ([]*models.NotificationThread, error)
|
||||
GetDoneNotifications(Type string, page int64) ([]*models.NotificationThread, error)
|
||||
@@ -514,26 +508,6 @@ func (gitea *GiteaTransport) SetLabels(owner, repo string, idx int64, labels []s
|
||||
return ret.Payload, nil
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) GetIssue(owner, repo string, idx int64) (*models.Issue, error) {
|
||||
ret, err := gitea.client.Issue.IssueGetIssue(
|
||||
issue.NewIssueGetIssueParams().WithOwner(owner).WithRepo(repo).WithIndex(idx),
|
||||
gitea.transport.DefaultAuthentication)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret.Payload, nil
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) UpdateIssue(owner, repo string, idx int64, options *models.EditIssueOption) (*models.Issue, error) {
|
||||
ret, err := gitea.client.Issue.IssueEditIssue(
|
||||
issue.NewIssueEditIssueParams().WithOwner(owner).WithRepo(repo).WithIndex(idx).WithBody(options),
|
||||
gitea.transport.DefaultAuthentication)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret.Payload, nil
|
||||
}
|
||||
|
||||
const (
|
||||
GiteaNotificationType_Pull = "Pull"
|
||||
)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"src.opensuse.org/autogits/common/gitea-generated/client/repository"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/models"
|
||||
@@ -26,11 +28,13 @@ type MaintainershipMap struct {
|
||||
Data map[string][]string
|
||||
IsDir bool
|
||||
FetchPackage func(string) ([]byte, error)
|
||||
Raw []byte
|
||||
}
|
||||
|
||||
func parseMaintainershipData(data []byte) (*MaintainershipMap, error) {
|
||||
func ParseMaintainershipData(data []byte) (*MaintainershipMap, error) {
|
||||
maintainers := &MaintainershipMap{
|
||||
Data: make(map[string][]string),
|
||||
Raw: data,
|
||||
}
|
||||
if err := json.Unmarshal(data, &maintainers.Data); err != nil {
|
||||
return nil, err
|
||||
@@ -59,7 +63,7 @@ func FetchProjectMaintainershipData(gitea GiteaMaintainershipReader, org, prjGit
|
||||
}
|
||||
}
|
||||
|
||||
m, err := parseMaintainershipData(data)
|
||||
m, err := ParseMaintainershipData(data)
|
||||
if m != nil {
|
||||
m.IsDir = dir
|
||||
m.FetchPackage = func(pkg string) ([]byte, error) {
|
||||
@@ -164,13 +168,135 @@ func (data *MaintainershipMap) IsApproved(pkg string, reviews []*models.PullRevi
|
||||
return false
|
||||
}
|
||||
|
||||
func (data *MaintainershipMap) modifyInplace(writer io.StringWriter) error {
|
||||
var original map[string][]string
|
||||
if err := json.Unmarshal(data.Raw, &original); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(bytes.NewReader(data.Raw))
|
||||
_, err := dec.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
output := ""
|
||||
lastPos := 0
|
||||
modified := false
|
||||
|
||||
type entry struct {
|
||||
key string
|
||||
valStart int
|
||||
valEnd int
|
||||
}
|
||||
var entries []entry
|
||||
|
||||
for dec.More() {
|
||||
kToken, _ := dec.Token()
|
||||
key := kToken.(string)
|
||||
var raw json.RawMessage
|
||||
dec.Decode(&raw)
|
||||
valEnd := int(dec.InputOffset())
|
||||
valStart := valEnd - len(raw)
|
||||
entries = append(entries, entry{key, valStart, valEnd})
|
||||
}
|
||||
|
||||
changed := make(map[string]bool)
|
||||
for k, v := range data.Data {
|
||||
if ov, ok := original[k]; !ok || !slices.Equal(v, ov) {
|
||||
changed[k] = true
|
||||
}
|
||||
}
|
||||
for k := range original {
|
||||
if _, ok := data.Data[k]; !ok {
|
||||
changed[k] = true
|
||||
}
|
||||
}
|
||||
|
||||
if len(changed) == 0 {
|
||||
_, err = writer.WriteString(string(data.Raw))
|
||||
return err
|
||||
}
|
||||
|
||||
for _, e := range entries {
|
||||
if v, ok := data.Data[e.key]; ok {
|
||||
prefix := string(data.Raw[lastPos:e.valStart])
|
||||
if modified && strings.TrimSpace(output) == "{" {
|
||||
if commaIdx := strings.Index(prefix, ","); commaIdx != -1 {
|
||||
if quoteIdx := strings.Index(prefix, "\""); quoteIdx == -1 || commaIdx < quoteIdx {
|
||||
prefix = prefix[:commaIdx] + prefix[commaIdx+1:]
|
||||
}
|
||||
}
|
||||
}
|
||||
output += prefix
|
||||
if changed[e.key] {
|
||||
slices.Sort(v)
|
||||
newVal, _ := json.Marshal(v)
|
||||
output += string(newVal)
|
||||
modified = true
|
||||
} else {
|
||||
output += string(data.Raw[e.valStart:e.valEnd])
|
||||
}
|
||||
} else {
|
||||
// Deleted
|
||||
modified = true
|
||||
}
|
||||
lastPos = e.valEnd
|
||||
}
|
||||
output += string(data.Raw[lastPos:])
|
||||
|
||||
// Handle additions (simplistic: at the end)
|
||||
for k, v := range data.Data {
|
||||
if _, ok := original[k]; !ok {
|
||||
slices.Sort(v)
|
||||
newVal, _ := json.Marshal(v)
|
||||
keyStr, _ := json.Marshal(k)
|
||||
|
||||
// Insert before closing brace
|
||||
if idx := strings.LastIndex(output, "}"); idx != -1 {
|
||||
prefix := output[:idx]
|
||||
suffix := output[idx:]
|
||||
|
||||
trimmedPrefix := strings.TrimRight(prefix, " \n\r\t")
|
||||
if !strings.HasSuffix(trimmedPrefix, "{") && !strings.HasSuffix(trimmedPrefix, ",") {
|
||||
// find the actual position of the last non-whitespace character in prefix
|
||||
lastCharIdx := strings.LastIndexAny(prefix, "]}0123456789\"")
|
||||
if lastCharIdx != -1 {
|
||||
prefix = prefix[:lastCharIdx+1] + "," + prefix[lastCharIdx+1:]
|
||||
}
|
||||
}
|
||||
|
||||
insertion := fmt.Sprintf(" %s: %s", string(keyStr), string(newVal))
|
||||
if !strings.HasSuffix(prefix, "\n") {
|
||||
insertion = "\n" + insertion
|
||||
}
|
||||
output = prefix + insertion + "\n" + suffix
|
||||
modified = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if modified {
|
||||
_, err := writer.WriteString(output)
|
||||
return err
|
||||
}
|
||||
_, err = writer.WriteString(string(data.Raw))
|
||||
return err
|
||||
}
|
||||
|
||||
func (data *MaintainershipMap) WriteMaintainershipFile(writer io.StringWriter) error {
|
||||
if data.IsDir {
|
||||
return fmt.Errorf("Not implemented")
|
||||
}
|
||||
|
||||
writer.WriteString("{\n")
|
||||
if len(data.Raw) > 0 {
|
||||
if err := data.modifyInplace(writer); err == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to full write
|
||||
writer.WriteString("{\n")
|
||||
if d, ok := data.Data[""]; ok {
|
||||
eol := ","
|
||||
if len(data.Data) == 1 {
|
||||
@@ -181,17 +307,12 @@ func (data *MaintainershipMap) WriteMaintainershipFile(writer io.StringWriter) e
|
||||
writer.WriteString(fmt.Sprintf(" \"\": %s%s\n", string(str), eol))
|
||||
}
|
||||
|
||||
keys := make([]string, len(data.Data))
|
||||
i := 0
|
||||
keys := make([]string, 0, len(data.Data))
|
||||
for pkg := range data.Data {
|
||||
if pkg == "" {
|
||||
continue
|
||||
}
|
||||
keys[i] = pkg
|
||||
i++
|
||||
}
|
||||
if len(keys) >= i {
|
||||
keys = slices.Delete(keys, i, len(keys))
|
||||
keys = append(keys, pkg)
|
||||
}
|
||||
slices.Sort(keys)
|
||||
for i, pkg := range keys {
|
||||
|
||||
@@ -208,6 +208,7 @@ func TestMaintainershipFileWrite(t *testing.T) {
|
||||
name string
|
||||
is_dir bool
|
||||
maintainers map[string][]string
|
||||
raw []byte
|
||||
expected_output string
|
||||
expected_error error
|
||||
}{
|
||||
@@ -231,6 +232,43 @@ func TestMaintainershipFileWrite(t *testing.T) {
|
||||
},
|
||||
expected_output: "{\n \"\": [\"one\",\"two\"],\n \"foo\": [\"byte\",\"four\"],\n \"pkg1\": []\n}\n",
|
||||
},
|
||||
{
|
||||
name: "surgical modification",
|
||||
maintainers: map[string][]string{
|
||||
"": {"one", "two"},
|
||||
"foo": {"byte", "four", "newone"},
|
||||
"pkg1": {},
|
||||
},
|
||||
raw: []byte("{\n \"\": [\"one\",\"two\"],\n \"foo\": [\"byte\",\"four\"],\n \"pkg1\": []\n}\n"),
|
||||
expected_output: "{\n \"\": [\"one\",\"two\"],\n \"foo\": [\"byte\",\"four\",\"newone\"],\n \"pkg1\": []\n}\n",
|
||||
},
|
||||
{
|
||||
name: "no change",
|
||||
maintainers: map[string][]string{
|
||||
"": {"one", "two"},
|
||||
"foo": {"byte", "four"},
|
||||
"pkg1": {},
|
||||
},
|
||||
raw: []byte("{\n \"\": [\"one\",\"two\"],\n \"foo\": [\"byte\",\"four\"],\n \"pkg1\": []\n}\n"),
|
||||
expected_output: "{\n \"\": [\"one\",\"two\"],\n \"foo\": [\"byte\",\"four\"],\n \"pkg1\": []\n}\n",
|
||||
},
|
||||
{
|
||||
name: "surgical addition",
|
||||
maintainers: map[string][]string{
|
||||
"": {"one"},
|
||||
"new": {"user"},
|
||||
},
|
||||
raw: []byte("{\n \"\": [ \"one\" ]\n}\n"),
|
||||
expected_output: "{\n \"\": [ \"one\" ],\n \"new\": [\"user\"]\n}\n",
|
||||
},
|
||||
{
|
||||
name: "surgical deletion",
|
||||
maintainers: map[string][]string{
|
||||
"": {"one"},
|
||||
},
|
||||
raw: []byte("{\n \"\": [\"one\"],\n \"old\": [\"user\"]\n}\n"),
|
||||
expected_output: "{\n \"\": [\"one\"]\n}\n",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@@ -239,6 +277,7 @@ func TestMaintainershipFileWrite(t *testing.T) {
|
||||
data := common.MaintainershipMap{
|
||||
Data: test.maintainers,
|
||||
IsDir: test.is_dir,
|
||||
Raw: test.raw,
|
||||
}
|
||||
|
||||
if err := data.WriteMaintainershipFile(&b); err != test.expected_error {
|
||||
@@ -248,7 +287,7 @@ func TestMaintainershipFileWrite(t *testing.T) {
|
||||
output := b.String()
|
||||
|
||||
if test.expected_output != output {
|
||||
t.Fatal("unexpected output:", output, "Expecting:", test.expected_output)
|
||||
t.Fatalf("unexpected output:\n%q\nExpecting:\n%q", output, test.expected_output)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -144,69 +144,6 @@ func (c *MockGiteaLabelSettterSetLabelsCall) DoAndReturn(f func(string, string,
|
||||
return c
|
||||
}
|
||||
|
||||
// MockGiteaIssueFetcher is a mock of GiteaIssueFetcher interface.
|
||||
type MockGiteaIssueFetcher struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockGiteaIssueFetcherMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockGiteaIssueFetcherMockRecorder is the mock recorder for MockGiteaIssueFetcher.
|
||||
type MockGiteaIssueFetcherMockRecorder struct {
|
||||
mock *MockGiteaIssueFetcher
|
||||
}
|
||||
|
||||
// NewMockGiteaIssueFetcher creates a new mock instance.
|
||||
func NewMockGiteaIssueFetcher(ctrl *gomock.Controller) *MockGiteaIssueFetcher {
|
||||
mock := &MockGiteaIssueFetcher{ctrl: ctrl}
|
||||
mock.recorder = &MockGiteaIssueFetcherMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockGiteaIssueFetcher) EXPECT() *MockGiteaIssueFetcherMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetIssue mocks base method.
|
||||
func (m *MockGiteaIssueFetcher) GetIssue(org, repo string, idx int64) (*models.Issue, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetIssue", org, repo, idx)
|
||||
ret0, _ := ret[0].(*models.Issue)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetIssue indicates an expected call of GetIssue.
|
||||
func (mr *MockGiteaIssueFetcherMockRecorder) GetIssue(org, repo, idx any) *MockGiteaIssueFetcherGetIssueCall {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIssue", reflect.TypeOf((*MockGiteaIssueFetcher)(nil).GetIssue), org, repo, idx)
|
||||
return &MockGiteaIssueFetcherGetIssueCall{Call: call}
|
||||
}
|
||||
|
||||
// MockGiteaIssueFetcherGetIssueCall wrap *gomock.Call
|
||||
type MockGiteaIssueFetcherGetIssueCall struct {
|
||||
*gomock.Call
|
||||
}
|
||||
|
||||
// Return rewrite *gomock.Call.Return
|
||||
func (c *MockGiteaIssueFetcherGetIssueCall) Return(arg0 *models.Issue, arg1 error) *MockGiteaIssueFetcherGetIssueCall {
|
||||
c.Call = c.Call.Return(arg0, arg1)
|
||||
return c
|
||||
}
|
||||
|
||||
// Do rewrite *gomock.Call.Do
|
||||
func (c *MockGiteaIssueFetcherGetIssueCall) Do(f func(string, string, int64) (*models.Issue, error)) *MockGiteaIssueFetcherGetIssueCall {
|
||||
c.Call = c.Call.Do(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// DoAndReturn rewrite *gomock.Call.DoAndReturn
|
||||
func (c *MockGiteaIssueFetcherGetIssueCall) DoAndReturn(f func(string, string, int64) (*models.Issue, error)) *MockGiteaIssueFetcherGetIssueCall {
|
||||
c.Call = c.Call.DoAndReturn(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// MockGiteaTimelineFetcher is a mock of GiteaTimelineFetcher interface.
|
||||
type MockGiteaTimelineFetcher struct {
|
||||
ctrl *gomock.Controller
|
||||
@@ -1506,45 +1443,6 @@ func (c *MockGiteaReviewFetcherAndRequesterAndUnrequesterUnrequestReviewCall) Do
|
||||
return c
|
||||
}
|
||||
|
||||
// UpdateIssue mocks base method.
|
||||
func (m *MockGiteaReviewFetcherAndRequesterAndUnrequester) UpdateIssue(org, repo string, idx int64, options *models.EditIssueOption) (*models.Issue, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateIssue", org, repo, idx, options)
|
||||
ret0, _ := ret[0].(*models.Issue)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// UpdateIssue indicates an expected call of UpdateIssue.
|
||||
func (mr *MockGiteaReviewFetcherAndRequesterAndUnrequesterMockRecorder) UpdateIssue(org, repo, idx, options any) *MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateIssue", reflect.TypeOf((*MockGiteaReviewFetcherAndRequesterAndUnrequester)(nil).UpdateIssue), org, repo, idx, options)
|
||||
return &MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall{Call: call}
|
||||
}
|
||||
|
||||
// MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall wrap *gomock.Call
|
||||
type MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall struct {
|
||||
*gomock.Call
|
||||
}
|
||||
|
||||
// Return rewrite *gomock.Call.Return
|
||||
func (c *MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall) Return(arg0 *models.Issue, arg1 error) *MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall {
|
||||
c.Call = c.Call.Return(arg0, arg1)
|
||||
return c
|
||||
}
|
||||
|
||||
// Do rewrite *gomock.Call.Do
|
||||
func (c *MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall) Do(f func(string, string, int64, *models.EditIssueOption) (*models.Issue, error)) *MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall {
|
||||
c.Call = c.Call.Do(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// DoAndReturn rewrite *gomock.Call.DoAndReturn
|
||||
func (c *MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall) DoAndReturn(f func(string, string, int64, *models.EditIssueOption) (*models.Issue, error)) *MockGiteaReviewFetcherAndRequesterAndUnrequesterUpdateIssueCall {
|
||||
c.Call = c.Call.DoAndReturn(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// MockGiteaUnreviewTimelineFetcher is a mock of GiteaUnreviewTimelineFetcher interface.
|
||||
type MockGiteaUnreviewTimelineFetcher struct {
|
||||
ctrl *gomock.Controller
|
||||
@@ -1651,45 +1549,6 @@ func (c *MockGiteaUnreviewTimelineFetcherUnrequestReviewCall) DoAndReturn(f func
|
||||
return c
|
||||
}
|
||||
|
||||
// UpdateIssue mocks base method.
|
||||
func (m *MockGiteaUnreviewTimelineFetcher) UpdateIssue(org, repo string, idx int64, options *models.EditIssueOption) (*models.Issue, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateIssue", org, repo, idx, options)
|
||||
ret0, _ := ret[0].(*models.Issue)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// UpdateIssue indicates an expected call of UpdateIssue.
|
||||
func (mr *MockGiteaUnreviewTimelineFetcherMockRecorder) UpdateIssue(org, repo, idx, options any) *MockGiteaUnreviewTimelineFetcherUpdateIssueCall {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateIssue", reflect.TypeOf((*MockGiteaUnreviewTimelineFetcher)(nil).UpdateIssue), org, repo, idx, options)
|
||||
return &MockGiteaUnreviewTimelineFetcherUpdateIssueCall{Call: call}
|
||||
}
|
||||
|
||||
// MockGiteaUnreviewTimelineFetcherUpdateIssueCall wrap *gomock.Call
|
||||
type MockGiteaUnreviewTimelineFetcherUpdateIssueCall struct {
|
||||
*gomock.Call
|
||||
}
|
||||
|
||||
// Return rewrite *gomock.Call.Return
|
||||
func (c *MockGiteaUnreviewTimelineFetcherUpdateIssueCall) Return(arg0 *models.Issue, arg1 error) *MockGiteaUnreviewTimelineFetcherUpdateIssueCall {
|
||||
c.Call = c.Call.Return(arg0, arg1)
|
||||
return c
|
||||
}
|
||||
|
||||
// Do rewrite *gomock.Call.Do
|
||||
func (c *MockGiteaUnreviewTimelineFetcherUpdateIssueCall) Do(f func(string, string, int64, *models.EditIssueOption) (*models.Issue, error)) *MockGiteaUnreviewTimelineFetcherUpdateIssueCall {
|
||||
c.Call = c.Call.Do(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// DoAndReturn rewrite *gomock.Call.DoAndReturn
|
||||
func (c *MockGiteaUnreviewTimelineFetcherUpdateIssueCall) DoAndReturn(f func(string, string, int64, *models.EditIssueOption) (*models.Issue, error)) *MockGiteaUnreviewTimelineFetcherUpdateIssueCall {
|
||||
c.Call = c.Call.DoAndReturn(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// MockGiteaReviewRequester is a mock of GiteaReviewRequester interface.
|
||||
type MockGiteaReviewRequester struct {
|
||||
ctrl *gomock.Controller
|
||||
@@ -1825,45 +1684,6 @@ func (c *MockGiteaReviewUnrequesterUnrequestReviewCall) DoAndReturn(f func(strin
|
||||
return c
|
||||
}
|
||||
|
||||
// UpdateIssue mocks base method.
|
||||
func (m *MockGiteaReviewUnrequester) UpdateIssue(org, repo string, idx int64, options *models.EditIssueOption) (*models.Issue, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateIssue", org, repo, idx, options)
|
||||
ret0, _ := ret[0].(*models.Issue)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// UpdateIssue indicates an expected call of UpdateIssue.
|
||||
func (mr *MockGiteaReviewUnrequesterMockRecorder) UpdateIssue(org, repo, idx, options any) *MockGiteaReviewUnrequesterUpdateIssueCall {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateIssue", reflect.TypeOf((*MockGiteaReviewUnrequester)(nil).UpdateIssue), org, repo, idx, options)
|
||||
return &MockGiteaReviewUnrequesterUpdateIssueCall{Call: call}
|
||||
}
|
||||
|
||||
// MockGiteaReviewUnrequesterUpdateIssueCall wrap *gomock.Call
|
||||
type MockGiteaReviewUnrequesterUpdateIssueCall struct {
|
||||
*gomock.Call
|
||||
}
|
||||
|
||||
// Return rewrite *gomock.Call.Return
|
||||
func (c *MockGiteaReviewUnrequesterUpdateIssueCall) Return(arg0 *models.Issue, arg1 error) *MockGiteaReviewUnrequesterUpdateIssueCall {
|
||||
c.Call = c.Call.Return(arg0, arg1)
|
||||
return c
|
||||
}
|
||||
|
||||
// Do rewrite *gomock.Call.Do
|
||||
func (c *MockGiteaReviewUnrequesterUpdateIssueCall) Do(f func(string, string, int64, *models.EditIssueOption) (*models.Issue, error)) *MockGiteaReviewUnrequesterUpdateIssueCall {
|
||||
c.Call = c.Call.Do(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// DoAndReturn rewrite *gomock.Call.DoAndReturn
|
||||
func (c *MockGiteaReviewUnrequesterUpdateIssueCall) DoAndReturn(f func(string, string, int64, *models.EditIssueOption) (*models.Issue, error)) *MockGiteaReviewUnrequesterUpdateIssueCall {
|
||||
c.Call = c.Call.DoAndReturn(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// MockGiteaReviewer is a mock of GiteaReviewer interface.
|
||||
type MockGiteaReviewer struct {
|
||||
ctrl *gomock.Controller
|
||||
@@ -2658,45 +2478,6 @@ func (c *MockGiteaGetDoneNotificationsCall) DoAndReturn(f func(string, int64) ([
|
||||
return c
|
||||
}
|
||||
|
||||
// GetIssue mocks base method.
|
||||
func (m *MockGitea) GetIssue(org, repo string, idx int64) (*models.Issue, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetIssue", org, repo, idx)
|
||||
ret0, _ := ret[0].(*models.Issue)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetIssue indicates an expected call of GetIssue.
|
||||
func (mr *MockGiteaMockRecorder) GetIssue(org, repo, idx any) *MockGiteaGetIssueCall {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIssue", reflect.TypeOf((*MockGitea)(nil).GetIssue), org, repo, idx)
|
||||
return &MockGiteaGetIssueCall{Call: call}
|
||||
}
|
||||
|
||||
// MockGiteaGetIssueCall wrap *gomock.Call
|
||||
type MockGiteaGetIssueCall struct {
|
||||
*gomock.Call
|
||||
}
|
||||
|
||||
// Return rewrite *gomock.Call.Return
|
||||
func (c *MockGiteaGetIssueCall) Return(arg0 *models.Issue, arg1 error) *MockGiteaGetIssueCall {
|
||||
c.Call = c.Call.Return(arg0, arg1)
|
||||
return c
|
||||
}
|
||||
|
||||
// Do rewrite *gomock.Call.Do
|
||||
func (c *MockGiteaGetIssueCall) Do(f func(string, string, int64) (*models.Issue, error)) *MockGiteaGetIssueCall {
|
||||
c.Call = c.Call.Do(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// DoAndReturn rewrite *gomock.Call.DoAndReturn
|
||||
func (c *MockGiteaGetIssueCall) DoAndReturn(f func(string, string, int64) (*models.Issue, error)) *MockGiteaGetIssueCall {
|
||||
c.Call = c.Call.DoAndReturn(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// GetIssueComments mocks base method.
|
||||
func (m *MockGitea) GetIssueComments(org, project string, issueNo int64) ([]*models.Comment, error) {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -3525,45 +3306,6 @@ func (c *MockGiteaUnrequestReviewCall) DoAndReturn(f func(string, string, int64,
|
||||
return c
|
||||
}
|
||||
|
||||
// UpdateIssue mocks base method.
|
||||
func (m *MockGitea) UpdateIssue(org, repo string, idx int64, options *models.EditIssueOption) (*models.Issue, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateIssue", org, repo, idx, options)
|
||||
ret0, _ := ret[0].(*models.Issue)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// UpdateIssue indicates an expected call of UpdateIssue.
|
||||
func (mr *MockGiteaMockRecorder) UpdateIssue(org, repo, idx, options any) *MockGiteaUpdateIssueCall {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateIssue", reflect.TypeOf((*MockGitea)(nil).UpdateIssue), org, repo, idx, options)
|
||||
return &MockGiteaUpdateIssueCall{Call: call}
|
||||
}
|
||||
|
||||
// MockGiteaUpdateIssueCall wrap *gomock.Call
|
||||
type MockGiteaUpdateIssueCall struct {
|
||||
*gomock.Call
|
||||
}
|
||||
|
||||
// Return rewrite *gomock.Call.Return
|
||||
func (c *MockGiteaUpdateIssueCall) Return(arg0 *models.Issue, arg1 error) *MockGiteaUpdateIssueCall {
|
||||
c.Call = c.Call.Return(arg0, arg1)
|
||||
return c
|
||||
}
|
||||
|
||||
// Do rewrite *gomock.Call.Do
|
||||
func (c *MockGiteaUpdateIssueCall) Do(f func(string, string, int64, *models.EditIssueOption) (*models.Issue, error)) *MockGiteaUpdateIssueCall {
|
||||
c.Call = c.Call.Do(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// DoAndReturn rewrite *gomock.Call.DoAndReturn
|
||||
func (c *MockGiteaUpdateIssueCall) DoAndReturn(f func(string, string, int64, *models.EditIssueOption) (*models.Issue, error)) *MockGiteaUpdateIssueCall {
|
||||
c.Call = c.Call.DoAndReturn(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// UpdatePullRequest mocks base method.
|
||||
func (m *MockGitea) UpdatePullRequest(org, repo string, num int64, options *models.EditPullRequestOption) (*models.PullRequest, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
61
common/pr.go
61
common/pr.go
@@ -6,9 +6,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"src.opensuse.org/autogits/common/gitea-generated/client/repository"
|
||||
@@ -652,8 +650,6 @@ func (rs *PRSet) Merge(gitea GiteaReviewUnrequester, git Git) error {
|
||||
}
|
||||
|
||||
// FF all non-prj git and unrequest reviews.
|
||||
newRepoIssues := make(map[int64]string) // issue index -> org/repo
|
||||
|
||||
for _, prinfo := range rs.PRs {
|
||||
// remove pending review requests
|
||||
repo := prinfo.PR.Base.Repo
|
||||
@@ -675,15 +671,6 @@ func (rs *PRSet) Merge(gitea GiteaReviewUnrequester, git Git) error {
|
||||
if rs.IsPrjGitPR(prinfo.PR) {
|
||||
continue
|
||||
}
|
||||
|
||||
isNewRepo := false
|
||||
for _, l := range prinfo.PR.Labels {
|
||||
if l.Name == Label_NewRepository {
|
||||
isNewRepo = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
br := rs.Config.Branch
|
||||
if len(br) == 0 {
|
||||
// if branch is unspecified, take it from the PR as it
|
||||
@@ -692,30 +679,11 @@ func (rs *PRSet) Merge(gitea GiteaReviewUnrequester, git Git) error {
|
||||
} else if br != prinfo.PR.Base.Name {
|
||||
panic(prinfo.PR.Base.Name + " is expected to match " + br)
|
||||
}
|
||||
|
||||
if isNewRepo {
|
||||
// Extract issue reference from body: "See issue #XYZ"
|
||||
rx := regexp.MustCompile(`See issue #(\d+)`)
|
||||
if matches := rx.FindStringSubmatch(prinfo.PR.Body); len(matches) > 1 {
|
||||
if issueIdx, err := strconv.ParseInt(matches[1], 10, 64); err == nil {
|
||||
// We need to know which project git this issue belongs to.
|
||||
// Since the PR set is linked to a ProjectGit, we can use its org/repo.
|
||||
prjGitOrg, prjGitRepo, _ := rs.Config.GetPrjGit()
|
||||
newRepoIssues[issueIdx] = prjGitOrg + "/" + prjGitRepo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prinfo.RemoteName, err = git.GitClone(repo.Name, br, repo.SSHURL)
|
||||
PanicOnError(err)
|
||||
git.GitExecOrPanic(repo.Name, "fetch", prinfo.RemoteName, head.Sha)
|
||||
git.GitExecOrPanic(repo.Name, "merge", "--ff", head.Sha)
|
||||
|
||||
if isNewRepo {
|
||||
LogInfo("Force-pushing new repository branch", br, "to", head.Sha)
|
||||
// we don't merge, we just set the branch to this commit
|
||||
} else {
|
||||
git.GitExecOrPanic(repo.Name, "merge", "--ff", head.Sha)
|
||||
}
|
||||
}
|
||||
|
||||
// push changes
|
||||
@@ -730,37 +698,12 @@ func (rs *PRSet) Merge(gitea GiteaReviewUnrequester, git Git) error {
|
||||
}
|
||||
repo := prinfo.PR.Base.Repo
|
||||
|
||||
isNewRepo := false
|
||||
for _, l := range prinfo.PR.Labels {
|
||||
if l.Name == Label_NewRepository {
|
||||
isNewRepo = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !IsDryRun {
|
||||
if isNewRepo {
|
||||
git.GitExecOrPanic(repo.Name, "push", "-f", prinfo.RemoteName, prinfo.PR.Head.Sha+":"+prinfo.PR.Base.Name)
|
||||
} else {
|
||||
git.GitExecOrPanic(repo.Name, "push", prinfo.RemoteName)
|
||||
}
|
||||
git.GitExecOrPanic(repo.Name, "push", prinfo.RemoteName)
|
||||
} else {
|
||||
LogInfo("*** WOULD push", repo.Name, "to", prinfo.RemoteName)
|
||||
}
|
||||
}
|
||||
|
||||
// Close referencing issues
|
||||
if !IsDryRun {
|
||||
for issueIdx, prjPath := range newRepoIssues {
|
||||
parts := strings.Split(prjPath, "/")
|
||||
if len(parts) == 2 {
|
||||
LogInfo("Closing issue", prjPath+"#"+strconv.FormatInt(issueIdx, 10))
|
||||
gitea.UpdateIssue(parts[0], parts[1], issueIdx, &models.EditIssueOption{
|
||||
State: "closed",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
package common_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"go.uber.org/mock/gomock"
|
||||
"src.opensuse.org/autogits/common"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/models"
|
||||
mock_common "src.opensuse.org/autogits/common/mock"
|
||||
)
|
||||
|
||||
func TestFetchPRSet_Linkage(t *testing.T) {
|
||||
config := &common.AutogitConfig{
|
||||
Organization: "target-org",
|
||||
GitProjectName: "test-org/prjgit#main",
|
||||
}
|
||||
|
||||
// 1. Mock a package PR
|
||||
pkgPR := &models.PullRequest{
|
||||
Index: 101,
|
||||
State: "open",
|
||||
Base: &models.PRBranchInfo{
|
||||
Ref: "main",
|
||||
Repo: &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
},
|
||||
},
|
||||
Head: &models.PRBranchInfo{Sha: "pkg-sha"},
|
||||
}
|
||||
|
||||
// 2. Mock a ProjectGit PR that references the package PR
|
||||
prjGitPR := &models.PullRequest{
|
||||
Index: 500,
|
||||
State: "open",
|
||||
Base: &models.PRBranchInfo{
|
||||
Ref: "main",
|
||||
Name: "main",
|
||||
Repo: &models.Repository{
|
||||
Name: "prjgit",
|
||||
Owner: &models.User{UserName: "test-org"},
|
||||
},
|
||||
},
|
||||
Body: "Forwarded PRs: pkg1\n\nPR: target-org/pkg1!101",
|
||||
}
|
||||
|
||||
t.Run("Fetch from ProjectGit PR", func(t *testing.T) {
|
||||
ctl := gomock.NewController(t)
|
||||
defer ctl.Finish()
|
||||
mockGitea := mock_common.NewMockGiteaPRTimelineReviewFetcher(ctl)
|
||||
|
||||
// Expect fetch of prjGitPR
|
||||
mockGitea.EXPECT().GetPullRequest("test-org", "prjgit", int64(500)).Return(prjGitPR, nil)
|
||||
// Expect fetch of pkgPR because it's linked in body
|
||||
mockGitea.EXPECT().GetPullRequest("target-org", "pkg1", int64(101)).Return(pkgPR, nil)
|
||||
|
||||
// Expect review fetching (part of FetchPRSet)
|
||||
mockGitea.EXPECT().GetPullRequestReviews(gomock.Any(), gomock.Any(), gomock.Any()).Return([]*models.PullReview{}, nil).AnyTimes()
|
||||
mockGitea.EXPECT().GetTimeline(gomock.Any(), gomock.Any(), gomock.Any()).Return([]*models.TimelineComment{}, nil).AnyTimes()
|
||||
|
||||
prset, err := common.FetchPRSet("bot", mockGitea, "test-org", "prjgit", 500, config)
|
||||
if err != nil {
|
||||
t.Fatalf("FetchPRSet failed: %v", err)
|
||||
}
|
||||
|
||||
if len(prset.PRs) != 2 {
|
||||
t.Errorf("Expected 2 PRs in set, got %d", len(prset.PRs))
|
||||
}
|
||||
|
||||
if !prset.IsConsistent() {
|
||||
t.Error("PR set should be consistent")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Fetch from Package PR via Timeline", func(t *testing.T) {
|
||||
ctl := gomock.NewController(t)
|
||||
defer ctl.Finish()
|
||||
mockGitea := mock_common.NewMockGiteaPRTimelineReviewFetcher(ctl)
|
||||
|
||||
// 1. FetchPRSet for pkgPR will call LastPrjGitRefOnTimeline
|
||||
mockGitea.EXPECT().GetTimeline("target-org", "pkg1", int64(101)).Return([]*models.TimelineComment{
|
||||
{
|
||||
Type: common.TimelineCommentType_PullRequestRef,
|
||||
RefIssue: &models.Issue{
|
||||
Index: 500,
|
||||
Body: "PR: target-org/pkg1!101",
|
||||
Repository: &models.RepositoryMeta{
|
||||
Owner: "test-org",
|
||||
Name: "prjgit",
|
||||
},
|
||||
User: &models.User{UserName: "bot"},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
|
||||
// 2. It will then fetch the prjGitPR found in timeline (twice in LastPrjGitRefOnTimeline)
|
||||
mockGitea.EXPECT().GetPullRequest("test-org", "prjgit", int64(500)).Return(prjGitPR, nil).Times(2)
|
||||
|
||||
// 3. Then it will recursively fetch linked PRs from prjGitPR body in readPRData
|
||||
mockGitea.EXPECT().GetPullRequest("target-org", "pkg1", int64(101)).Return(pkgPR, nil)
|
||||
|
||||
// Review fetching for all PRs in the set
|
||||
mockGitea.EXPECT().GetPullRequestReviews(gomock.Any(), gomock.Any(), gomock.Any()).Return([]*models.PullReview{}, nil).AnyTimes()
|
||||
mockGitea.EXPECT().GetTimeline("test-org", "prjgit", int64(500)).Return([]*models.TimelineComment{}, nil).AnyTimes()
|
||||
mockGitea.EXPECT().GetTimeline("target-org", "pkg1", int64(101)).Return([]*models.TimelineComment{}, nil).AnyTimes()
|
||||
|
||||
prset, err := common.FetchPRSet("bot", mockGitea, "target-org", "pkg1", 101, config)
|
||||
if err != nil {
|
||||
t.Fatalf("FetchPRSet failed: %v", err)
|
||||
}
|
||||
|
||||
if len(prset.PRs) != 2 {
|
||||
t.Errorf("Expected 2 PRs in set, got %d", len(prset.PRs))
|
||||
}
|
||||
|
||||
prjPRInfo, err := prset.GetPrjGitPR()
|
||||
if err != nil || prjPRInfo.PR.Index != 500 {
|
||||
t.Errorf("Expected ProjectGit PR 500 to be found, got %v", prjPRInfo)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package common_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"go.uber.org/mock/gomock"
|
||||
"src.opensuse.org/autogits/common"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/models"
|
||||
mock_common "src.opensuse.org/autogits/common/mock"
|
||||
)
|
||||
|
||||
func TestPRSet_Merge_Special(t *testing.T) {
|
||||
ctl := gomock.NewController(t)
|
||||
defer ctl.Finish()
|
||||
|
||||
mockGitea := mock_common.NewMockGiteaReviewUnrequester(ctl)
|
||||
mockGit := mock_common.NewMockGit(ctl)
|
||||
|
||||
config := &common.AutogitConfig{
|
||||
Organization: "target-org",
|
||||
GitProjectName: "test-org/prjgit#main",
|
||||
Branch: "main",
|
||||
}
|
||||
|
||||
// 1. Regular ProjectGit PR
|
||||
prjGitPR := &models.PullRequest{
|
||||
Index: 500,
|
||||
Base: &models.PRBranchInfo{
|
||||
Ref: "main",
|
||||
Name: "main",
|
||||
Repo: &models.Repository{Name: "prjgit", Owner: &models.User{UserName: "test-org"}, SSHURL: "prj-ssh-url"},
|
||||
Sha: "base-sha",
|
||||
},
|
||||
Head: &models.PRBranchInfo{Sha: "prj-head-sha"},
|
||||
}
|
||||
|
||||
// 2. "new/New Repository" Package PR
|
||||
newPkgPR := &models.PullRequest{
|
||||
Index: 101,
|
||||
Base: &models.PRBranchInfo{
|
||||
Ref: "main",
|
||||
Name: "main",
|
||||
Repo: &models.Repository{Name: "new-pkg", Owner: &models.User{UserName: "target-org"}, SSHURL: "pkg-ssh-url"},
|
||||
},
|
||||
Head: &models.PRBranchInfo{Sha: "pkg-head-sha"},
|
||||
Labels: []*models.Label{
|
||||
{Name: "new/New Repository"},
|
||||
},
|
||||
Body: "See issue #123",
|
||||
}
|
||||
|
||||
prset := &common.PRSet{
|
||||
Config: config,
|
||||
PRs: []*common.PRInfo{
|
||||
{PR: prjGitPR},
|
||||
{PR: newPkgPR},
|
||||
},
|
||||
}
|
||||
|
||||
common.IsDryRun = false
|
||||
|
||||
// Mock expectations for Merge
|
||||
// Clone and fetch for PrjGit
|
||||
mockGit.EXPECT().GitClone("_ObsPrj", "main", "prj-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitExecOrPanic("_ObsPrj", "fetch", "origin", "prj-head-sha")
|
||||
// mockGit.EXPECT().GitExecWithOutputOrPanic("_ObsPrj", "merge-base", "HEAD", "base-sha", "prj-head-sha").Return("base-sha")
|
||||
mockGit.EXPECT().GitExec("_ObsPrj", "merge", "--no-ff", "-m", gomock.Any(), "prj-head-sha").Return(nil)
|
||||
|
||||
// Unrequest reviews
|
||||
mockGitea.EXPECT().UnrequestReview("test-org", "prjgit", int64(500), gomock.Any()).Return(nil)
|
||||
mockGitea.EXPECT().UnrequestReview("target-org", "new-pkg", int64(101), gomock.Any()).Return(nil)
|
||||
|
||||
// Clone and fetch for new-pkg
|
||||
mockGit.EXPECT().GitClone("new-pkg", "main", "pkg-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitExecOrPanic("new-pkg", "fetch", "origin", "pkg-head-sha")
|
||||
|
||||
// Pushing changes
|
||||
mockGit.EXPECT().GitExecOrPanic("_ObsPrj", "push", "origin")
|
||||
// Special push for new repo: git push -f origin pkg-head-sha:main
|
||||
mockGit.EXPECT().GitExecOrPanic("new-pkg", "push", "-f", "origin", "pkg-head-sha:main")
|
||||
|
||||
// Closing issue
|
||||
mockGitea.EXPECT().UpdateIssue("test-org", "prjgit", int64(123), gomock.Any()).DoAndReturn(func(org, repo string, idx int64, opt *models.EditIssueOption) (*models.Issue, error) {
|
||||
if opt.State != "closed" {
|
||||
t.Errorf("Expected issue state to be closed, got %s", opt.State)
|
||||
}
|
||||
return nil, nil
|
||||
})
|
||||
|
||||
err := prset.Merge(mockGitea, mockGit)
|
||||
if err != nil {
|
||||
t.Fatalf("Merge failed: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,8 @@ func reviewsToTimeline(reviews []*models.PullReview) []*models.TimelineComment {
|
||||
}
|
||||
|
||||
func TestPR(t *testing.T) {
|
||||
return
|
||||
|
||||
baseConfig := common.AutogitConfig{
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
@@ -78,21 +80,21 @@ func TestPR(t *testing.T) {
|
||||
{
|
||||
name: "Error fetching PullRequest",
|
||||
data: []prdata{
|
||||
{pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "open"}, pr_err: errors.New("Missing PR")},
|
||||
{pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "opened"}, pr_err: errors.New("Missing PR")},
|
||||
},
|
||||
prjGitPRIndex: -1,
|
||||
},
|
||||
{
|
||||
name: "Error fetching PullRequest in PrjGit",
|
||||
data: []prdata{
|
||||
{pr: &models.PullRequest{Body: "PR: foo/barPrj#22", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "open"}, pr_err: errors.New("missing PR")},
|
||||
{pr: &models.PullRequest{Body: "", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "PR: foo/barPrj#22", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "opened"}, pr_err: errors.New("missing PR")},
|
||||
{pr: &models.PullRequest{Body: "", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, State: "opened"}},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Error fetching prjgit",
|
||||
data: []prdata{
|
||||
{pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "opened"}},
|
||||
},
|
||||
resLen: 1,
|
||||
prjGitPRIndex: -1,
|
||||
@@ -100,20 +102,8 @@ func TestPR(t *testing.T) {
|
||||
{
|
||||
name: "Review set is consistent",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#22", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "open"},
|
||||
timeline: []*models.TimelineComment{
|
||||
{
|
||||
Type: common.TimelineCommentType_PullRequestRef,
|
||||
RefIssue: &models.Issue{
|
||||
Index: 22,
|
||||
Repository: &models.RepositoryMeta{Name: "barPrj", Owner: "foo"},
|
||||
User: &models.User{UserName: "test"},
|
||||
Body: "PR: test/repo#42",
|
||||
},
|
||||
},
|
||||
}},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo#42", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "opened"}},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo#42", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, State: "opened"}},
|
||||
},
|
||||
resLen: 2,
|
||||
prjGitPRIndex: 1,
|
||||
@@ -123,21 +113,8 @@ func TestPR(t *testing.T) {
|
||||
{
|
||||
name: "Review set is consistent: 1pkg",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#22", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "open"},
|
||||
timeline: []*models.TimelineComment{
|
||||
{
|
||||
Type: common.TimelineCommentType_PullRequestRef,
|
||||
RefIssue: &models.Issue{
|
||||
Index: 22,
|
||||
Repository: &models.RepositoryMeta{Name: "barPrj", Owner: "foo"},
|
||||
User: &models.User{UserName: "test"},
|
||||
Body: "PR: test/repo#42",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo#42", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "PR: foo/barPrj#22", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "opened"}},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo#42", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, State: "opened"}},
|
||||
},
|
||||
resLen: 2,
|
||||
prjGitPRIndex: 1,
|
||||
@@ -146,22 +123,9 @@ func TestPR(t *testing.T) {
|
||||
{
|
||||
name: "Review set is consistent: 2pkg",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "some desc\nPR: foo/barPrj#22", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "open"},
|
||||
timeline: []*models.TimelineComment{
|
||||
{
|
||||
Type: common.TimelineCommentType_PullRequestRef,
|
||||
RefIssue: &models.Issue{
|
||||
Index: 22,
|
||||
Repository: &models.RepositoryMeta{Name: "barPrj", Owner: "foo"},
|
||||
User: &models.User{UserName: "test"},
|
||||
Body: "PR: test/repo#42\nPR: test/repo2#41",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo#42\nPR: test/repo2#41", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "some other desc\nPR: foo/barPrj#22", Index: 41, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo2", Owner: &models.User{UserName: "test"}}}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "some desc", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "opened"}},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo#42\nPR: test/repo2#41", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, State: "opened"}},
|
||||
{pr: &models.PullRequest{Body: "some other desc\nPR: foo/fer#33", Index: 41, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo2", Owner: &models.User{UserName: "test"}}}, State: "opened"}},
|
||||
},
|
||||
resLen: 3,
|
||||
prjGitPRIndex: 1,
|
||||
@@ -171,7 +135,7 @@ func TestPR(t *testing.T) {
|
||||
name: "Review set of prjgit PR is consistent",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -190,23 +154,10 @@ func TestPR(t *testing.T) {
|
||||
{
|
||||
name: "Review set is consistent: 2pkg",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#222", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "open"},
|
||||
timeline: []*models.TimelineComment{
|
||||
{
|
||||
Type: common.TimelineCommentType_PullRequestRef,
|
||||
RefIssue: &models.Issue{
|
||||
Index: 22,
|
||||
Repository: &models.RepositoryMeta{Name: "barPrj", Owner: "foo"},
|
||||
User: &models.User{UserName: "test"},
|
||||
Body: "PR: test/repo#42\nPR: test/repo2#41",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo2#41", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo#42\nPR: test/repo2#41", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "PR: foo/barPrj#20", Index: 41, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo2", Owner: &models.User{UserName: "test"}}}, State: "open"}},
|
||||
{pr: &models.PullRequest{Body: "PR: foo/barPrj#222", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "test"}}}, State: "opened"}},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo2#41", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, State: "opened"}},
|
||||
{pr: &models.PullRequest{Body: "PR: test/repo#42\nPR: test/repo2#41", Index: 22, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, State: "opened"}},
|
||||
{pr: &models.PullRequest{Body: "PR: foo/barPrj#20", Index: 41, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo2", Owner: &models.User{UserName: "test"}}}, State: "opened"}},
|
||||
},
|
||||
resLen: 3,
|
||||
prjGitPRIndex: 2,
|
||||
@@ -216,7 +167,7 @@ func TestPR(t *testing.T) {
|
||||
name: "WIP PR is not approved",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "", Title: "WIP: some title", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "", Title: "WIP: some title", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -233,9 +184,10 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Manual review is missing", data: []prdata{
|
||||
name: "Manual review is missing",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -243,7 +195,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -260,15 +212,16 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
ManualMergeOnly: true,
|
||||
})
|
||||
}},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Manual review is done, via PrjGit",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "merge ok", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -276,7 +229,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -293,7 +246,7 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
ManualMergeOnly: true,
|
||||
})
|
||||
},
|
||||
@@ -302,7 +255,7 @@ func TestPR(t *testing.T) {
|
||||
name: "Manual review is done, via PrjGit",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "merge ok", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -310,7 +263,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -327,7 +280,7 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
ManualMergeOnly: true,
|
||||
ManualMergeProject: true,
|
||||
})
|
||||
@@ -337,7 +290,7 @@ func TestPR(t *testing.T) {
|
||||
name: "Manual review is not done, via PrjGit",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "merge ok", User: &models.User{UserName: "notm2"}, State: common.ReviewStateApproved},
|
||||
{Body: "merge not ok", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
@@ -346,7 +299,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -363,7 +316,7 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
ManualMergeOnly: true,
|
||||
ManualMergeProject: true,
|
||||
})
|
||||
@@ -373,7 +326,7 @@ func TestPR(t *testing.T) {
|
||||
name: "Manual review is done via PackageGit",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -381,7 +334,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "Merge ok", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -398,7 +351,7 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
ManualMergeOnly: true,
|
||||
})
|
||||
},
|
||||
@@ -407,7 +360,7 @@ func TestPR(t *testing.T) {
|
||||
name: "Manual review done via PkgGits",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20\nPR: foo/repo#21", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20\nPR: foo/repo#21", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -415,7 +368,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "Merge OK!", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -423,7 +376,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 21, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 21, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "merge ok", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -440,7 +393,7 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
ManualMergeOnly: true,
|
||||
})
|
||||
},
|
||||
@@ -449,7 +402,7 @@ func TestPR(t *testing.T) {
|
||||
name: "Manual review done via PkgGits not allowed",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20\nPR: foo/repo#21", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20\nPR: foo/repo#21", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -457,7 +410,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "Merge OK!", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -465,7 +418,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 21, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 21, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "merge ok", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -482,7 +435,7 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
ManualMergeOnly: true,
|
||||
ManualMergeProject: true,
|
||||
})
|
||||
@@ -492,7 +445,7 @@ func TestPR(t *testing.T) {
|
||||
name: "Manual review is is missing on one PR",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20\nPR: foo/repo#21", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/repo#20\nPR: foo/repo#21", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -500,7 +453,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 20, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -508,7 +461,7 @@ func TestPR(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 21, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "PR: foo/barPrj#42", Index: 21, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "repo", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m1"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super1"}, State: common.ReviewStateApproved},
|
||||
@@ -525,7 +478,7 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
ManualMergeOnly: true,
|
||||
})
|
||||
},
|
||||
@@ -534,7 +487,7 @@ func TestPR(t *testing.T) {
|
||||
name: "PR is approved with negative optional review",
|
||||
data: []prdata{
|
||||
{
|
||||
pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}, Name: "master"}, User: &models.User{UserName: "submitter"}, State: "open"},
|
||||
pr: &models.PullRequest{Body: "", Index: 42, Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "barPrj", Owner: &models.User{UserName: "foo"}}}, User: &models.User{UserName: "submitter"}, State: "opened"},
|
||||
reviews: []*models.PullReview{
|
||||
{Body: "LGTM", User: &models.User{UserName: "m2"}, State: common.ReviewStateApproved},
|
||||
{Body: "LGTM", User: &models.User{UserName: "super2"}, State: common.ReviewStateApproved},
|
||||
@@ -552,7 +505,7 @@ func TestPR(t *testing.T) {
|
||||
Reviewers: []string{"+super1", "*super2", "m1", "-m2", "~*bot"},
|
||||
Branch: "branch",
|
||||
Organization: "foo",
|
||||
GitProjectName: "barPrj#master",
|
||||
GitProjectName: "barPrj",
|
||||
}
|
||||
return common.FetchPRSet("test", mock, "foo", "barPrj", 42, &config)
|
||||
},
|
||||
@@ -566,31 +519,27 @@ func TestPR(t *testing.T) {
|
||||
review_mock := mock_common.NewMockGiteaPRChecker(ctl)
|
||||
// reviewer_mock := mock_common.NewMockGiteaReviewRequester(ctl)
|
||||
|
||||
prjGitOrg, prjGitRepo, _ := baseConfig.GetPrjGit()
|
||||
if test.reviewSetFetcher == nil { // if we are fetching the prjgit directly, the these mocks are not called
|
||||
if test.prjGitPRIndex >= 0 {
|
||||
pr_mock.EXPECT().GetPullRequest(prjGitOrg, prjGitRepo, int64(test.data[test.prjGitPRIndex].pr.Index)).
|
||||
Return(test.data[test.prjGitPRIndex].pr, test.data[test.prjGitPRIndex].pr_err).AnyTimes()
|
||||
pr_mock.EXPECT().GetPullRequest(baseConfig.Organization, baseConfig.GitProjectName, test.prjGitPRIndex).
|
||||
Return(test.data[test.prjGitPRIndex].pr, test.data[test.prjGitPRIndex].pr_err)
|
||||
} else if test.prjGitPRIndex < 0 {
|
||||
// no prjgit PR
|
||||
pr_mock.EXPECT().GetPullRequest(prjGitOrg, prjGitRepo, gomock.Any()).
|
||||
Return(nil, nil).AnyTimes()
|
||||
pr_mock.EXPECT().GetPullRequest(baseConfig.Organization, baseConfig.GitProjectName, gomock.Any()).
|
||||
Return(nil, nil)
|
||||
}
|
||||
}
|
||||
|
||||
var test_err error
|
||||
for _, data := range test.data {
|
||||
pr_mock.EXPECT().GetPullRequest(data.pr.Base.Repo.Owner.UserName, data.pr.Base.Repo.Name, data.pr.Index).Return(data.pr, data.pr_err).AnyTimes()
|
||||
if data.pr_err != nil {
|
||||
// test_err is not used and was causing a build error.
|
||||
// data.pr_err is directly used in the previous EXPECT call.
|
||||
test_err = data.pr_err
|
||||
}
|
||||
review_mock.EXPECT().GetPullRequestReviews(data.pr.Base.Repo.Owner.UserName, data.pr.Base.Repo.Name, data.pr.Index).Return(data.reviews, data.review_error).AnyTimes()
|
||||
if data.timeline == nil {
|
||||
data.timeline = reviewsToTimeline(data.reviews)
|
||||
}
|
||||
pr_mock.EXPECT().GetTimeline(data.pr.Base.Repo.Owner.UserName, data.pr.Base.Repo.Name, data.pr.Index).Return(data.timeline, nil).AnyTimes()
|
||||
pr_mock.EXPECT().GetPullRequestReviews(data.pr.Base.Repo.Owner.UserName, data.pr.Base.Repo.Name, data.pr.Index).Return(data.reviews, data.review_error).AnyTimes()
|
||||
|
||||
review_mock.EXPECT().GetPullRequestReviews(data.pr.Base.Repo.Owner.UserName, data.pr.Base.Repo.Name, data.pr.Index).Return(data.reviews, data.review_error).AnyTimes()
|
||||
review_mock.EXPECT().GetTimeline(data.pr.Base.Repo.Owner.UserName, data.pr.Base.Repo.Name, data.pr.Index).Return(data.timeline, nil).AnyTimes()
|
||||
}
|
||||
|
||||
@@ -603,12 +552,27 @@ func TestPR(t *testing.T) {
|
||||
res, err = common.FetchPRSet("test", pr_mock, "test", "repo", 42, &baseConfig)
|
||||
}
|
||||
|
||||
if res == nil {
|
||||
if err == nil {
|
||||
if test_err != nil {
|
||||
t.Fatal("Expected", test_err, "but got", err)
|
||||
}
|
||||
} else {
|
||||
if res != nil {
|
||||
t.Fatal("error but got ReviewSet?")
|
||||
}
|
||||
|
||||
if test.api_error != "" {
|
||||
if err.Error() != test.api_error {
|
||||
t.Fatal("expected", test.api_error, "but got", err)
|
||||
}
|
||||
} else if test_err != err {
|
||||
t.Fatal("expected", test_err, "but got", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if len(res.PRs) != test.resLen {
|
||||
t.Errorf("Test Case '%s': expected result len %d but got %d", test.name, test.resLen, len(res.PRs))
|
||||
if test.resLen != len(res.PRs) {
|
||||
t.Error("expected result len", test.resLen, "but got", len(res.PRs))
|
||||
}
|
||||
|
||||
PrjGitPR, err := res.GetPrjGitPR()
|
||||
@@ -619,9 +583,6 @@ func TestPR(t *testing.T) {
|
||||
}
|
||||
pr_found := false
|
||||
if test.prjGitPRIndex >= 0 {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
for i := range test.data {
|
||||
if PrjGitPR.PR == test.data[i].pr && i == test.prjGitPRIndex {
|
||||
t.Log("found at index", i)
|
||||
@@ -1165,6 +1126,7 @@ func TestFindMissingAndExtraReviewers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPRMerge(t *testing.T) {
|
||||
t.Skip("FAIL: No PrjGit PR found, missing calls")
|
||||
repoDir := t.TempDir()
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
@@ -1174,11 +1136,7 @@ func TestPRMerge(t *testing.T) {
|
||||
t.Fatal(string(out))
|
||||
}
|
||||
|
||||
t.Skip("No tests of PRMerge yet")
|
||||
return
|
||||
|
||||
common.ExtraGitParams = []string{
|
||||
"TZ=UTC",
|
||||
"GIT_CONFIG_COUNT=1",
|
||||
"GIT_CONFIG_KEY_0=protocol.file.allow",
|
||||
"GIT_CONFIG_VALUE_0=always",
|
||||
@@ -1193,7 +1151,7 @@ func TestPRMerge(t *testing.T) {
|
||||
|
||||
config := &common.AutogitConfig{
|
||||
Organization: "org",
|
||||
GitProjectName: "org/prj#main",
|
||||
GitProjectName: "org/prj#master",
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@@ -1205,10 +1163,8 @@ func TestPRMerge(t *testing.T) {
|
||||
name: "Merge base not merged in main",
|
||||
|
||||
pr: &models.PullRequest{
|
||||
Index: 1,
|
||||
Base: &models.PRBranchInfo{
|
||||
Name: "main",
|
||||
Sha: "96515c092626c716a4613ba4f68a8d1cc4894317658342c450e656390f524ec3", // "base_add_b1"
|
||||
Sha: "e8b0de43d757c96a9d2c7101f4bff404e322f53a1fa4041fb85d646110c38ad4", // "base_add_b1"
|
||||
Repo: &models.Repository{
|
||||
Name: "prj",
|
||||
Owner: &models.User{
|
||||
@@ -1218,7 +1174,7 @@ func TestPRMerge(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Head: &models.PRBranchInfo{
|
||||
Sha: "4119fc725dc11cdf11f982d5bb0a8ba2a138f1180c4323862a18b8e08def5603", // "base_add_b2"
|
||||
Sha: "88584433de1c917c1d773f62b82381848d882491940b5e9b427a540aa9057d9a", // "base_add_b2"
|
||||
},
|
||||
},
|
||||
mergeError: "Aborting merge",
|
||||
@@ -1227,10 +1183,8 @@ func TestPRMerge(t *testing.T) {
|
||||
name: "Merge conflict in modules, auto-resolved",
|
||||
|
||||
pr: &models.PullRequest{
|
||||
Index: 1,
|
||||
Base: &models.PRBranchInfo{
|
||||
Name: "main",
|
||||
Sha: "85f59f7aa732b742e58b48356cd46cb1ab1b5c4349eb5c0eda324e2dbea8f9e7",
|
||||
Sha: "4fbd1026b2d7462ebe9229a49100c11f1ad6555520a21ba515122d8bc41328a8",
|
||||
Repo: &models.Repository{
|
||||
Name: "prj",
|
||||
Owner: &models.User{
|
||||
@@ -1240,7 +1194,7 @@ func TestPRMerge(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Head: &models.PRBranchInfo{
|
||||
Sha: "4119fc725dc11cdf11f982d5bb0a8ba2a138f1180c4323862a18b8e08def5603", // "base_add_b2"
|
||||
Sha: "88584433de1c917c1d773f62b82381848d882491940b5e9b427a540aa9057d9a", // "base_add_b2"
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1252,13 +1206,11 @@ func TestPRMerge(t *testing.T) {
|
||||
mock := mock_common.NewMockGiteaPRTimelineReviewFetcher(ctl)
|
||||
reviewUnrequestMock := mock_common.NewMockGiteaReviewUnrequester(ctl)
|
||||
|
||||
reviewUnrequestMock.EXPECT().UnrequestReview(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
||||
reviewUnrequestMock.EXPECT().UnrequestReview(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
|
||||
|
||||
testDir := t.TempDir()
|
||||
t.Log("dir:", testDir)
|
||||
mock.EXPECT().GetPullRequest("org", "prj", int64(1)).Return(test.pr, nil)
|
||||
mock.EXPECT().GetTimeline("org", "prj", int64(1)).Return(nil, nil).AnyTimes()
|
||||
mock.EXPECT().GetPullRequestReviews("org", "prj", int64(1)).Return(nil, nil).AnyTimes()
|
||||
|
||||
set, err := common.FetchPRSet("test", mock, "org", "prj", 1, config)
|
||||
if err != nil {
|
||||
@@ -1279,11 +1231,11 @@ func TestPRMerge(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPRChanges(t *testing.T) {
|
||||
t.Skip("FAIL: unexpected calls, missing calls")
|
||||
tests := []struct {
|
||||
name string
|
||||
PRs []*models.PullRequest
|
||||
PrjPRs *models.PullRequest
|
||||
Timeline []*models.TimelineComment
|
||||
name string
|
||||
PRs []*models.PullRequest
|
||||
PrjPRs *models.PullRequest
|
||||
}{
|
||||
{
|
||||
name: "Pkg PR is closed",
|
||||
@@ -1295,22 +1247,10 @@ func TestPRChanges(t *testing.T) {
|
||||
},
|
||||
},
|
||||
PrjPRs: &models.PullRequest{
|
||||
Index: 42,
|
||||
Title: "some PR",
|
||||
Base: &models.PRBranchInfo{Name: "branch", Repo: &models.Repository{Name: "prjgit", Owner: &models.User{UserName: "org"}}},
|
||||
Base: &models.PRBranchInfo{Repo: &models.Repository{Name: "prjgit", Owner: &models.User{UserName: "org"}}},
|
||||
Body: "PR: org/repo#42",
|
||||
State: "open",
|
||||
},
|
||||
Timeline: []*models.TimelineComment{
|
||||
{
|
||||
Type: common.TimelineCommentType_PullRequestRef,
|
||||
RefIssue: &models.Issue{
|
||||
Index: 42,
|
||||
Repository: &models.RepositoryMeta{Name: "prjgit", Owner: "org"},
|
||||
User: &models.User{UserName: "user"},
|
||||
Body: "PR: org/repo#42",
|
||||
},
|
||||
},
|
||||
State: "opened",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1323,13 +1263,9 @@ func TestPRChanges(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
ctl := gomock.NewController(t)
|
||||
mock_fetcher := mock_common.NewMockGiteaPRTimelineReviewFetcher(ctl)
|
||||
mock_fetcher.EXPECT().GetPullRequest("org", "prjgit", int64(42)).Return(test.PrjPRs, nil).AnyTimes()
|
||||
mock_fetcher.EXPECT().GetTimeline("org", "prjgit", int64(42)).Return(nil, nil).AnyTimes()
|
||||
mock_fetcher.EXPECT().GetPullRequestReviews("org", "prjgit", int64(42)).Return(nil, nil).AnyTimes()
|
||||
mock_fetcher.EXPECT().GetPullRequest("org", "prjgit", int64(42)).Return(test.PrjPRs, nil)
|
||||
for _, pr := range test.PRs {
|
||||
mock_fetcher.EXPECT().GetPullRequest(pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name, pr.Index).Return(pr, nil)
|
||||
mock_fetcher.EXPECT().GetTimeline(pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name, pr.Index).Return(test.Timeline, nil).AnyTimes()
|
||||
mock_fetcher.EXPECT().GetPullRequestReviews(pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name, pr.Index).Return(nil, nil).AnyTimes()
|
||||
}
|
||||
|
||||
PRs, err := common.FetchPRSet("user", mock_fetcher, "org", "repo", 42, &config)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
set -x
|
||||
|
||||
export TZ=UTC
|
||||
export GIT_CONFIG_COUNT=2
|
||||
|
||||
export GIT_CONFIG_KEY_0=protocol.file.allow
|
||||
|
||||
98
utils/maintainer-update/main.go
Normal file
98
utils/maintainer-update/main.go
Normal file
@@ -0,0 +1,98 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
|
||||
"src.opensuse.org/autogits/common"
|
||||
)
|
||||
|
||||
var (
|
||||
pkg = flag.String("package", "", "Package to modify")
|
||||
rm = flag.Bool("rm", false, "Remove maintainer from package")
|
||||
add = flag.Bool("add", false, "Add maintainer to package")
|
||||
lint = flag.Bool("lint-only", false, "Reformat entire _maintainership.json only")
|
||||
)
|
||||
|
||||
const maintainershipFile = "_maintainership.json"
|
||||
|
||||
func WriteNewMaintainershipFile(m *common.MaintainershipMap, filename string) {
|
||||
f, err := os.Create(filename + ".new")
|
||||
common.PanicOnError(err)
|
||||
common.PanicOnError(m.WriteMaintainershipFile(f))
|
||||
common.PanicOnError(f.Close())
|
||||
common.PanicOnError(os.Rename(filename+".new", filename))
|
||||
}
|
||||
|
||||
func run() error {
|
||||
flag.Parse()
|
||||
|
||||
filename := maintainershipFile
|
||||
if *lint {
|
||||
if len(flag.Args()) > 0 {
|
||||
filename = flag.Arg(0)
|
||||
}
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(filename)
|
||||
if os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m, err := common.ParseMaintainershipData(data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to parse JSON: %w", err)
|
||||
}
|
||||
|
||||
if *lint {
|
||||
m.Raw = nil // forces a rewrite
|
||||
} else {
|
||||
users := flag.Args()
|
||||
if len(users) > 0 {
|
||||
maintainers, ok := m.Data[*pkg]
|
||||
if !ok && !*add {
|
||||
return fmt.Errorf("No package %s and not adding one.", *pkg)
|
||||
}
|
||||
|
||||
if *add {
|
||||
for _, u := range users {
|
||||
if !slices.Contains(maintainers, u) {
|
||||
maintainers = append(maintainers, u)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if *rm {
|
||||
newMaintainers := make([]string, 0, len(maintainers))
|
||||
for _, m := range maintainers {
|
||||
if !slices.Contains(users, m) {
|
||||
newMaintainers = append(newMaintainers, m)
|
||||
}
|
||||
}
|
||||
maintainers = newMaintainers
|
||||
}
|
||||
|
||||
if len(maintainers) > 0 {
|
||||
slices.Sort(maintainers)
|
||||
m.Data[*pkg] = maintainers
|
||||
} else {
|
||||
delete(m.Data, *pkg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WriteNewMaintainershipFile(m, filename)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := run(); err != nil {
|
||||
common.LogError(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
243
utils/maintainer-update/main_test.go
Normal file
243
utils/maintainer-update/main_test.go
Normal file
@@ -0,0 +1,243 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"os"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
if os.Getenv("BE_MAIN") == "1" {
|
||||
main()
|
||||
return
|
||||
}
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
inData string
|
||||
expectedOut string
|
||||
params []string
|
||||
expectedError string
|
||||
isDir bool
|
||||
}{
|
||||
{
|
||||
name: "add user to existing package",
|
||||
inData: `{"pkg1": ["user1"]}`,
|
||||
params: []string{"-package", "pkg1", "-add", "user2"},
|
||||
expectedOut: `{"pkg1": ["user1", "user2"]}`,
|
||||
},
|
||||
{
|
||||
name: "add user to new package",
|
||||
inData: `{"pkg1": ["user1"]}`,
|
||||
params: []string{"-package", "pkg2", "-add", "user2"},
|
||||
expectedOut: `{"pkg1": ["user1"], "pkg2": ["user2"]}`,
|
||||
},
|
||||
{
|
||||
name: "no-op with no users",
|
||||
inData: `{"pkg1": ["user1"]}`,
|
||||
params: []string{"-package", "pkg1", "-add"},
|
||||
expectedOut: `{"pkg1": ["user1"]}`,
|
||||
},
|
||||
{
|
||||
name: "add existing user",
|
||||
inData: `{"pkg1": ["user1", "user2"]}`,
|
||||
params: []string{"-package", "pkg1", "-add", "user2"},
|
||||
expectedOut: `{"pkg1": ["user1", "user2"]}`,
|
||||
},
|
||||
{
|
||||
name: "remove user from package",
|
||||
inData: `{"pkg1": ["user1", "user2"]}`,
|
||||
params: []string{"-package", "pkg1", "-rm", "user2"},
|
||||
expectedOut: `{"pkg1": ["user1"]}`,
|
||||
},
|
||||
{
|
||||
name: "remove last user from package",
|
||||
inData: `{"pkg1": ["user1"]}`,
|
||||
params: []string{"-package", "pkg1", "-rm", "user1"},
|
||||
expectedOut: `{}`,
|
||||
},
|
||||
{
|
||||
name: "remove non-existent user",
|
||||
inData: `{"pkg1": ["user1"]}`,
|
||||
params: []string{"-package", "pkg1", "-rm", "user2"},
|
||||
expectedOut: `{"pkg1": ["user1"]}`,
|
||||
},
|
||||
{
|
||||
name: "lint only unsorted",
|
||||
inData: `{"pkg1": ["user2", "user1"]}`,
|
||||
params: []string{"-lint-only"},
|
||||
expectedOut: `{"pkg1": ["user1", "user2"]}`,
|
||||
},
|
||||
{
|
||||
name: "lint only no changes",
|
||||
inData: `{"pkg1": ["user1", "user2"]}`,
|
||||
params: []string{"-lint-only"},
|
||||
expectedOut: `{"pkg1": ["user1", "user2"]}`,
|
||||
},
|
||||
{
|
||||
name: "no file",
|
||||
params: []string{},
|
||||
expectedError: "no such file or directory",
|
||||
},
|
||||
{
|
||||
name: "invalid json",
|
||||
inData: `{"pkg1": ["user1"`,
|
||||
params: []string{},
|
||||
expectedError: "Failed to parse JSON",
|
||||
},
|
||||
{
|
||||
name: "add and remove",
|
||||
inData: `{"pkg1": ["user1", "user2"]}`,
|
||||
params: []string{"-package", "pkg1", "-add", "user3"},
|
||||
expectedOut: `{"pkg1": ["user1", "user2", "user3"]}`,
|
||||
},
|
||||
{
|
||||
name: "lint specific file",
|
||||
inData: `{"pkg1": ["user2", "user1"]}`,
|
||||
params: []string{"-lint-only", "other.json"},
|
||||
expectedOut: `{"pkg1": ["user1", "user2"]}`,
|
||||
},
|
||||
{
|
||||
name: "add user to package when it was not there before",
|
||||
inData: `{}`,
|
||||
params: []string{"-package", "newpkg", "-add", "user1"},
|
||||
expectedOut: `{"newpkg": ["user1"]}`,
|
||||
},
|
||||
{
|
||||
name: "unreadable file (is a directory)",
|
||||
isDir: true,
|
||||
expectedError: "is a directory",
|
||||
},
|
||||
{
|
||||
name: "remove user from non-existent package",
|
||||
inData: `{"pkg1": ["user1"]}`,
|
||||
params: []string{"-package", "pkg2", "-rm", "user2"},
|
||||
expectedError: "No package pkg2 and not adding one.",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
oldWd, _ := os.Getwd()
|
||||
_ = os.Chdir(dir)
|
||||
defer os.Chdir(oldWd)
|
||||
|
||||
targetFile := maintainershipFile
|
||||
if tt.name == "lint specific file" {
|
||||
targetFile = "other.json"
|
||||
}
|
||||
|
||||
if tt.isDir {
|
||||
_ = os.Mkdir(targetFile, 0755)
|
||||
} else if tt.inData != "" {
|
||||
_ = os.WriteFile(targetFile, []byte(tt.inData), 0644)
|
||||
}
|
||||
|
||||
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
||||
pkg = flag.String("package", "", "Package to modify")
|
||||
rm = flag.Bool("rm", false, "Remove maintainer from package")
|
||||
add = flag.Bool("add", false, "Add maintainer to package")
|
||||
lint = flag.Bool("lint-only", false, "Reformat entire _maintainership.json only")
|
||||
|
||||
os.Args = append([]string{"cmd"}, tt.params...)
|
||||
err := run()
|
||||
|
||||
if tt.expectedError != "" {
|
||||
if err == nil {
|
||||
t.Fatalf("expected error containing %q, but got none", tt.expectedError)
|
||||
}
|
||||
if !strings.Contains(err.Error(), tt.expectedError) {
|
||||
t.Fatalf("expected error containing %q, got %q", tt.expectedError, err.Error())
|
||||
}
|
||||
} else if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
if tt.expectedOut != "" {
|
||||
data, _ := os.ReadFile(targetFile)
|
||||
var got, expected map[string][]string
|
||||
_ = json.Unmarshal(data, &got)
|
||||
_ = json.Unmarshal([]byte(tt.expectedOut), &expected)
|
||||
|
||||
if len(got) == 0 && len(expected) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(got, expected) {
|
||||
t.Fatalf("expected %v, got %v", expected, got)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMainRecursive(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
inData string
|
||||
expectedOut string
|
||||
params []string
|
||||
expectExit bool
|
||||
}{
|
||||
{
|
||||
name: "test main() via recursive call",
|
||||
inData: `{"pkg1": ["user1"]}`,
|
||||
params: []string{"-package", "pkg1", "-add", "user2"},
|
||||
expectedOut: `{"pkg1": ["user1", "user2"]}`,
|
||||
},
|
||||
{
|
||||
name: "test main() failure",
|
||||
params: []string{"-package", "pkg1"},
|
||||
expectExit: true,
|
||||
},
|
||||
}
|
||||
|
||||
exe, _ := os.Executable()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
oldWd, _ := os.Getwd()
|
||||
_ = os.Chdir(dir)
|
||||
defer os.Chdir(oldWd)
|
||||
|
||||
if tt.inData != "" {
|
||||
_ = os.WriteFile(maintainershipFile, []byte(tt.inData), 0644)
|
||||
}
|
||||
|
||||
cmd := exec.Command(exe, append([]string{"-test.run=None"}, tt.params...)...)
|
||||
cmd.Env = append(os.Environ(), "BE_MAIN=1")
|
||||
out, runErr := cmd.CombinedOutput()
|
||||
|
||||
if tt.expectExit {
|
||||
if runErr == nil {
|
||||
t.Fatalf("expected exit with error, but it succeeded")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if runErr != nil {
|
||||
t.Fatalf("unexpected error: %v: %s", runErr, string(out))
|
||||
}
|
||||
|
||||
if tt.expectedOut != "" {
|
||||
data, _ := os.ReadFile(maintainershipFile)
|
||||
var got, expected map[string][]string
|
||||
_ = json.Unmarshal(data, &got)
|
||||
_ = json.Unmarshal([]byte(tt.expectedOut), &expected)
|
||||
|
||||
if !reflect.DeepEqual(got, expected) {
|
||||
t.Fatalf("expected %v, got %v", expected, got)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -146,19 +146,15 @@ func main() {
|
||||
num, err := strconv.ParseInt(data[3], 10, 64)
|
||||
common.LogInfo("Processing:", org, "/", repo, "#", num)
|
||||
common.PanicOnError(err)
|
||||
if pr, err := Gitea.GetPullRequest(org, repo, num); err == nil && pr != nil {
|
||||
if err = ProcesPullRequest(pr, configs); err != nil {
|
||||
common.LogError("PR processor returned error", err)
|
||||
}
|
||||
} else if issue, err := Gitea.GetIssue(org, repo, num); err == nil && issue != nil {
|
||||
if err = ProcessIssue(issue, configs); err != nil {
|
||||
common.LogError("issue processor returned error:", err)
|
||||
}
|
||||
} else {
|
||||
common.LogError("Cannot fetch PR or Issue", err)
|
||||
pr, err := Gitea.GetPullRequest(org, repo, num)
|
||||
if err != nil {
|
||||
common.LogError("Cannot fetch PR", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = ProcesPullRequest(pr, configs); err != nil {
|
||||
common.LogError("processor returned error", err)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -190,14 +190,7 @@ func (pr *PRProcessor) SetSubmodulesToMatchPRSet(prset *common.PRSet) error {
|
||||
}
|
||||
|
||||
if !submodule_found {
|
||||
common.LogInfo("Adding new submodule", repo, "to PrjGit")
|
||||
ref := fmt.Sprintf(common.PrPattern, org, repo, idx)
|
||||
commitMsg := fmt.Sprintln("Add package", repo, "\n\nThis commit was autocreated by", GitAuthor, "\n\nreferencing PRs:\n", ref)
|
||||
|
||||
git.GitExecOrPanic(common.DefaultGitPrj, "submodule", "add", "-b", pr.PR.Base.Name, pr.PR.Base.Repo.SSHURL, repo)
|
||||
|
||||
updateSubmoduleInPR(repo, prHead, git)
|
||||
common.PanicOnError(git.GitExec(common.DefaultGitPrj, "commit", "-a", "-m", commitMsg))
|
||||
common.LogError("Failed to find expected repo:", repo)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -615,14 +608,6 @@ type RequestProcessor struct {
|
||||
recursive int
|
||||
}
|
||||
|
||||
func (w *RequestProcessor) Process(pr *models.PullRequest) error {
|
||||
configs, ok := w.configuredRepos[pr.Base.Repo.Owner.UserName]
|
||||
if !ok {
|
||||
return fmt.Errorf("no config found for org %s", pr.Base.Repo.Owner.UserName)
|
||||
}
|
||||
return ProcesPullRequest(pr, configs)
|
||||
}
|
||||
|
||||
func ProcesPullRequest(pr *models.PullRequest, configs []*common.AutogitConfig) error {
|
||||
if len(configs) < 1 {
|
||||
// ignoring pull request against unconfigured project (could be just regular sources?)
|
||||
@@ -639,153 +624,13 @@ func ProcesPullRequest(pr *models.PullRequest, configs []*common.AutogitConfig)
|
||||
return PRProcessor.Process(pr)
|
||||
}
|
||||
|
||||
func ProcessIssue(issue *models.Issue, configs []*common.AutogitConfig) error {
|
||||
title := issue.Title
|
||||
/*
|
||||
org := issue.Repository.Owner
|
||||
repo := issue.Repository.Name
|
||||
idx := issue.Index
|
||||
*/
|
||||
const BranchPrefix = "refs/heads/"
|
||||
branch := issue.Ref
|
||||
|
||||
if strings.HasPrefix(branch, BranchPrefix) {
|
||||
branch = strings.TrimPrefix(branch, BranchPrefix)
|
||||
} else {
|
||||
common.LogDebug("Invalid branch specified:", branch, ". Using default.")
|
||||
branch = ""
|
||||
func (w *RequestProcessor) Process(pr *models.PullRequest) error {
|
||||
configs, ok := w.configuredRepos[pr.Base.Repo.Owner.UserName]
|
||||
if !ok {
|
||||
common.LogError("*** Cannot find config for org:", pr.Base.Repo.Owner.UserName)
|
||||
return fmt.Errorf("*** Cannot find config for org: %s", pr.Base.Repo.Owner.UserName)
|
||||
}
|
||||
|
||||
// out, _ := json.MarshalIndent(issue, "", " ")
|
||||
// common.LogDebug(string(out))
|
||||
common.LogDebug("issue processing:", common.IssueToString(issue), "@", branch)
|
||||
|
||||
if len(title) > 5 && strings.EqualFold(title[0:5], "[ADD]") {
|
||||
// we need "New Package" label and "Approval Required" label, unless already approved
|
||||
// either via Label "Approved" or via review comment.
|
||||
NewIssues := common.FindNewReposInIssueBody(issue.Body)
|
||||
if NewIssues == nil {
|
||||
common.LogDebug("No new repos found in issue body")
|
||||
return nil
|
||||
}
|
||||
|
||||
org := issue.Repository.Owner
|
||||
repo := issue.Repository.Name
|
||||
|
||||
config := common.AutogitConfigs(configs).GetPrjGitConfig(org, repo, branch)
|
||||
if config == nil {
|
||||
return fmt.Errorf("Cannot find config for %s/%s#%s", org, repo, branch)
|
||||
}
|
||||
|
||||
git, err := GitHandler.CreateGitHandler(config.Organization)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer git.Close()
|
||||
|
||||
for _, nr := range NewIssues.Repos {
|
||||
targetRepo, err := Gitea.GetRepository(config.Organization, nr.PackageName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if targetRepo == nil {
|
||||
common.LogInfo("Repository", config.Organization+"/"+nr.PackageName, "does not exist. Labeling issue.")
|
||||
if !common.IsDryRun {
|
||||
Gitea.SetLabels(org, repo, issue.Index, []string{config.Label(common.Label_NewRepository)})
|
||||
}
|
||||
common.LogInfo("Done for now.")
|
||||
continue
|
||||
}
|
||||
|
||||
// Initialize repository if needed
|
||||
remoteName, err := git.GitClone(nr.PackageName, "", targetRepo.SSHURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err = git.GitRemoteHead(nr.PackageName, remoteName, branch); err != nil {
|
||||
common.LogInfo("Branch", branch, "missing in", nr.PackageName, ". Creating orphan branch.")
|
||||
|
||||
git.GitExecOrPanic(nr.PackageName, "checkout", "--orphan", branch)
|
||||
git.GitExecOrPanic(nr.PackageName, "rm", "-rf", ".")
|
||||
git.GitExecOrPanic(nr.PackageName, "commit", "--allow-empty", "-m", "Initial empty branch")
|
||||
if !common.IsDryRun {
|
||||
git.GitExecOrPanic(nr.PackageName, "push", remoteName, branch)
|
||||
}
|
||||
}
|
||||
|
||||
// Create Pull Request
|
||||
srcRepo, err := Gitea.GetRepository(nr.Organization, nr.Repository)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if srcRepo == nil {
|
||||
common.LogError("Source repository not found:", nr.Organization+"/"+nr.Repository)
|
||||
continue
|
||||
}
|
||||
|
||||
if srcRepo.Parent == nil {
|
||||
common.LogError("Source has no parents.")
|
||||
continue
|
||||
}
|
||||
|
||||
// Check that fork/parent repository relationship exists
|
||||
if srcRepo.Parent.Name != targetRepo.Name || srcRepo.Parent.Owner.UserName != targetRepo.Owner.UserName {
|
||||
common.LogError("Source repository is not fork of the Target repository. Fork of:", srcRepo.Parent.Owner.UserName+"/"+srcRepo.Parent.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
srcBranch := nr.Branch
|
||||
if srcBranch == "" {
|
||||
srcBranch = srcRepo.DefaultBranch
|
||||
}
|
||||
|
||||
head := nr.Organization + ":" + srcBranch
|
||||
isBranch := false
|
||||
// Hash can be branch name! Check if it's a branch or tag on the remote
|
||||
out, err := git.GitExecWithOutput(nr.PackageName, "ls-remote", "--heads", srcRepo.SSHURL, srcBranch)
|
||||
if err == nil && strings.Contains(out, "refs/heads/"+srcBranch) {
|
||||
isBranch = true
|
||||
}
|
||||
|
||||
if !isBranch {
|
||||
tempBranch := fmt.Sprintf("new_package_%d_%s", issue.Index, nr.PackageName)
|
||||
// Re-clone or use existing if branch check was done above
|
||||
remoteName, err := git.GitClone(nr.PackageName, branch, targetRepo.SSHURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
git.GitExecOrPanic(nr.PackageName, "remote", "add", "source", srcRepo.SSHURL)
|
||||
git.GitExecOrPanic(nr.PackageName, "fetch", "source", srcBranch)
|
||||
git.GitExecOrPanic(nr.PackageName, "checkout", "-B", tempBranch, "FETCH_HEAD")
|
||||
if !common.IsDryRun {
|
||||
git.GitExecOrPanic(nr.PackageName, "push", "-f", remoteName, tempBranch)
|
||||
}
|
||||
head = tempBranch
|
||||
}
|
||||
|
||||
title := fmt.Sprintf("Add package %s", nr.PackageName)
|
||||
body := fmt.Sprintf("See issue #%d", issue.Index)
|
||||
pr, err, isNew := Gitea.CreatePullRequestIfNotExist(targetRepo, head, branch, title, body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if isNew {
|
||||
Gitea.SetLabels(config.Organization, nr.PackageName, pr.Index, []string{config.Label(common.Label_NewRepository)})
|
||||
}
|
||||
}
|
||||
} else if len(title) > 4 && strings.EqualFold(title[0:4], "[RM]") {
|
||||
// to remove a package, no approval is required. This should happen via
|
||||
// project git PR reviews
|
||||
} else {
|
||||
common.LogError("Non-standard issue created. Ignoring", common.IssueToString(issue))
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
return ProcesPullRequest(pr, configs)
|
||||
}
|
||||
|
||||
func (w *RequestProcessor) ProcessFunc(request *common.Request) (err error) {
|
||||
@@ -816,18 +661,6 @@ func (w *RequestProcessor) ProcessFunc(request *common.Request) (err error) {
|
||||
common.LogError("Cannot find PR for issue:", req.Repository.Owner.Username, req.Repository.Name, int64(req.Issue.Number))
|
||||
return err
|
||||
}
|
||||
} else if req, ok := request.Data.(*common.IssueWebhookEvent); ok {
|
||||
issue, err := Gitea.GetIssue(req.Repository.Owner.Username, req.Repository.Name, int64(req.Issue.Number))
|
||||
if err != nil {
|
||||
common.LogError("Cannot find issue for issue event:", req.Repository.Owner.Username, req.Repository.Name, int64(req.Issue.Number))
|
||||
return err
|
||||
}
|
||||
configs, ok := w.configuredRepos[req.Repository.Owner.Username]
|
||||
if !ok {
|
||||
common.LogError("*** Cannot find config for org:", req.Repository.Owner.Username)
|
||||
return nil
|
||||
}
|
||||
return ProcessIssue(issue, configs)
|
||||
} else {
|
||||
common.LogError("*** Invalid data format for PR processing.")
|
||||
return fmt.Errorf("*** Invalid data format for PR processing.")
|
||||
|
||||
@@ -1,357 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"go.uber.org/mock/gomock"
|
||||
"src.opensuse.org/autogits/common"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/models"
|
||||
mock_common "src.opensuse.org/autogits/common/mock"
|
||||
)
|
||||
|
||||
func TestProcessIssue_Add(t *testing.T) {
|
||||
ctl := gomock.NewController(t)
|
||||
defer ctl.Finish()
|
||||
|
||||
gitea := mock_common.NewMockGitea(ctl)
|
||||
Gitea = gitea
|
||||
common.IsDryRun = false
|
||||
|
||||
config := &common.AutogitConfig{
|
||||
Organization: "target-org",
|
||||
GitProjectName: "test-org/test-prj#main",
|
||||
}
|
||||
configs := []*common.AutogitConfig{config}
|
||||
|
||||
issue := &models.Issue{
|
||||
Title: "[ADD] pkg1",
|
||||
Body: "src-org/pkg1#master",
|
||||
Index: 123,
|
||||
Repository: &models.RepositoryMeta{
|
||||
Owner: "test-org",
|
||||
Name: "test-prj",
|
||||
},
|
||||
Ref: "refs/heads/main",
|
||||
}
|
||||
|
||||
t.Run("Repository does not exist - labels issue", func(t *testing.T) {
|
||||
mockGitGen := mock_common.NewMockGitHandlerGenerator(ctl)
|
||||
GitHandler = mockGitGen
|
||||
mockGit := mock_common.NewMockGit(ctl)
|
||||
|
||||
mockGitGen.EXPECT().CreateGitHandler("target-org").Return(mockGit, nil)
|
||||
mockGit.EXPECT().Close().Return(nil)
|
||||
|
||||
gitea.EXPECT().GetRepository("target-org", "pkg1").Return(nil, nil)
|
||||
gitea.EXPECT().SetLabels("test-org", "test-prj", int64(123), []string{"new/New Repository"}).Return(nil, nil)
|
||||
|
||||
err := ProcessIssue(issue, configs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Source is SHA - creates temp branch in target", func(t *testing.T) {
|
||||
mockGitGen := mock_common.NewMockGitHandlerGenerator(ctl)
|
||||
GitHandler = mockGitGen
|
||||
mockGit := mock_common.NewMockGit(ctl)
|
||||
|
||||
mockGitGen.EXPECT().CreateGitHandler("target-org").Return(mockGit, nil)
|
||||
mockGit.EXPECT().GetPath().Return("/tmp/test").AnyTimes()
|
||||
mockGit.EXPECT().Close().Return(nil)
|
||||
|
||||
targetRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
SSHURL: "target-ssh-url",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
}
|
||||
srcRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
SSHURL: "src-ssh-url",
|
||||
DefaultBranch: "master",
|
||||
Owner: &models.User{UserName: "src-org"},
|
||||
Parent: &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
},
|
||||
}
|
||||
|
||||
issueSHA := &models.Issue{
|
||||
Title: "[ADD] pkg1",
|
||||
Body: "src-org/pkg1#abcdef0123456789abcdef0123456789abcdef01",
|
||||
Index: 123,
|
||||
Repository: &models.RepositoryMeta{Owner: "test-org", Name: "test-prj"},
|
||||
Ref: "refs/heads/main",
|
||||
}
|
||||
|
||||
gitea.EXPECT().GetRepository("target-org", "pkg1").Return(targetRepo, nil)
|
||||
mockGit.EXPECT().GitClone("pkg1", "", "target-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitRemoteHead("pkg1", "origin", "main").Return("some-sha", nil)
|
||||
|
||||
gitea.EXPECT().GetRepository("src-org", "pkg1").Return(srcRepo, nil)
|
||||
mockGit.EXPECT().GitExecWithOutput("pkg1", "ls-remote", "--heads", "src-ssh-url", "abcdef0123456789abcdef0123456789abcdef01").Return("", nil)
|
||||
|
||||
// SHA source logic
|
||||
tempBranch := "new_package_123_pkg1"
|
||||
mockGit.EXPECT().GitClone("pkg1", "main", "target-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitExecOrPanic("pkg1", "remote", "add", "source", "src-ssh-url")
|
||||
mockGit.EXPECT().GitExecOrPanic("pkg1", "fetch", "source", "abcdef0123456789abcdef0123456789abcdef01")
|
||||
mockGit.EXPECT().GitExecOrPanic("pkg1", "checkout", "-B", tempBranch, "FETCH_HEAD")
|
||||
mockGit.EXPECT().GitExecOrPanic("pkg1", "push", "-f", "origin", tempBranch)
|
||||
|
||||
// PR creation using temp branch
|
||||
gitea.EXPECT().CreatePullRequestIfNotExist(targetRepo, tempBranch, "main", gomock.Any(), gomock.Any()).Return(&models.PullRequest{Index: 456}, nil, false)
|
||||
|
||||
err := ProcessIssue(issueSHA, configs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Repository exists - continue processing and create PR", func(t *testing.T) {
|
||||
mockGitGen := mock_common.NewMockGitHandlerGenerator(ctl)
|
||||
GitHandler = mockGitGen
|
||||
mockGit := mock_common.NewMockGit(ctl)
|
||||
|
||||
mockGitGen.EXPECT().CreateGitHandler("target-org").Return(mockGit, nil)
|
||||
mockGit.EXPECT().Close().Return(nil)
|
||||
|
||||
targetRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
SSHURL: "target-ssh-url",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
}
|
||||
srcRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
SSHURL: "src-ssh-url",
|
||||
DefaultBranch: "master",
|
||||
Owner: &models.User{UserName: "src-org"},
|
||||
Parent: &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
},
|
||||
}
|
||||
|
||||
gitea.EXPECT().GetRepository("target-org", "pkg1").Return(targetRepo, nil)
|
||||
// 4. Branch check - exists via local git
|
||||
mockGit.EXPECT().GitClone("pkg1", "", "target-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitRemoteHead("pkg1", "origin", "main").Return("some-sha", nil)
|
||||
|
||||
// 5. Source repo fetch
|
||||
gitea.EXPECT().GetRepository("src-org", "pkg1").Return(srcRepo, nil)
|
||||
// Check if source is a branch via ls-remote
|
||||
mockGit.EXPECT().GitExecWithOutput("pkg1", "ls-remote", "--heads", "src-ssh-url", "master").Return("src-sha refs/heads/master", nil)
|
||||
|
||||
// PR creation
|
||||
packagePR := &models.PullRequest{
|
||||
Index: 456,
|
||||
Base: &models.PRBranchInfo{
|
||||
Ref: "main",
|
||||
Repo: targetRepo,
|
||||
Name: "main",
|
||||
},
|
||||
Head: &models.PRBranchInfo{
|
||||
Ref: "master",
|
||||
Repo: srcRepo,
|
||||
Sha: "src-sha",
|
||||
},
|
||||
URL: "http://gitea/pr/456",
|
||||
}
|
||||
gitea.EXPECT().CreatePullRequestIfNotExist(targetRepo, "src-org:master", "main", gomock.Any(), gomock.Any()).Return(packagePR, nil, true)
|
||||
gitea.EXPECT().SetLabels("target-org", "pkg1", int64(456), []string{"new/New Repository"}).Return(nil, nil)
|
||||
|
||||
err := ProcessIssue(issue, configs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Source repository is not fork of target repository - aborts", func(t *testing.T) {
|
||||
mockGitGen := mock_common.NewMockGitHandlerGenerator(ctl)
|
||||
GitHandler = mockGitGen
|
||||
mockGit := mock_common.NewMockGit(ctl)
|
||||
|
||||
mockGitGen.EXPECT().CreateGitHandler("target-org").Return(mockGit, nil)
|
||||
mockGit.EXPECT().Close().Return(nil)
|
||||
|
||||
targetRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
SSHURL: "target-ssh-url",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
}
|
||||
srcRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "src-org"},
|
||||
Parent: &models.Repository{
|
||||
Name: "other-repo",
|
||||
Owner: &models.User{UserName: "other-org"},
|
||||
},
|
||||
}
|
||||
|
||||
gitea.EXPECT().GetRepository("target-org", "pkg1").Return(targetRepo, nil)
|
||||
mockGit.EXPECT().GitClone("pkg1", "", "target-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitRemoteHead("pkg1", "origin", "main").Return("some-sha", nil)
|
||||
|
||||
gitea.EXPECT().GetRepository("src-org", "pkg1").Return(srcRepo, nil)
|
||||
|
||||
err := ProcessIssue(issue, configs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Source repository is fork of target repository - proceeds", func(t *testing.T) {
|
||||
mockGitGen := mock_common.NewMockGitHandlerGenerator(ctl)
|
||||
GitHandler = mockGitGen
|
||||
mockGit := mock_common.NewMockGit(ctl)
|
||||
|
||||
mockGitGen.EXPECT().CreateGitHandler("target-org").Return(mockGit, nil)
|
||||
mockGit.EXPECT().Close().Return(nil)
|
||||
|
||||
targetRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
SSHURL: "target-ssh-url",
|
||||
}
|
||||
srcRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "src-org"},
|
||||
SSHURL: "src-ssh-url",
|
||||
Parent: &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
},
|
||||
DefaultBranch: "master",
|
||||
}
|
||||
|
||||
gitea.EXPECT().GetRepository("target-org", "pkg1").Return(targetRepo, nil)
|
||||
mockGit.EXPECT().GitClone("pkg1", "", "target-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitRemoteHead("pkg1", "origin", "main").Return("some-sha", nil)
|
||||
|
||||
gitea.EXPECT().GetRepository("src-org", "pkg1").Return(srcRepo, nil)
|
||||
mockGit.EXPECT().GitExecWithOutput("pkg1", "ls-remote", "--heads", "src-ssh-url", "master").Return("src-sha refs/heads/master", nil)
|
||||
gitea.EXPECT().CreatePullRequestIfNotExist(targetRepo, "src-org:master", "main", gomock.Any(), gomock.Any()).Return(&models.PullRequest{Index: 456}, nil, false)
|
||||
|
||||
err := ProcessIssue(issue, configs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Source repository has no parent (not a fork) - aborts", func(t *testing.T) {
|
||||
mockGitGen := mock_common.NewMockGitHandlerGenerator(ctl)
|
||||
GitHandler = mockGitGen
|
||||
mockGit := mock_common.NewMockGit(ctl)
|
||||
|
||||
mockGitGen.EXPECT().CreateGitHandler("target-org").Return(mockGit, nil)
|
||||
mockGit.EXPECT().Close().Return(nil)
|
||||
|
||||
targetRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
SSHURL: "target-ssh-url",
|
||||
}
|
||||
srcRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "src-org"},
|
||||
SSHURL: "src-ssh-url",
|
||||
Parent: nil,
|
||||
DefaultBranch: "master",
|
||||
}
|
||||
|
||||
gitea.EXPECT().GetRepository("target-org", "pkg1").Return(targetRepo, nil)
|
||||
mockGit.EXPECT().GitClone("pkg1", "", "target-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitRemoteHead("pkg1", "origin", "main").Return("some-sha", nil)
|
||||
|
||||
gitea.EXPECT().GetRepository("src-org", "pkg1").Return(srcRepo, nil)
|
||||
|
||||
err := ProcessIssue(issue, configs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Target branch missing - creates orphan branch", func(t *testing.T) {
|
||||
mockGitGen := mock_common.NewMockGitHandlerGenerator(ctl)
|
||||
GitHandler = mockGitGen
|
||||
mockGit := mock_common.NewMockGit(ctl)
|
||||
|
||||
mockGitGen.EXPECT().CreateGitHandler("target-org").Return(mockGit, nil)
|
||||
mockGit.EXPECT().GetPath().Return("/tmp/test").AnyTimes()
|
||||
mockGit.EXPECT().Close().Return(nil)
|
||||
|
||||
targetRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
SSHURL: "target-ssh-url",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
}
|
||||
srcRepo := &models.Repository{
|
||||
Name: "pkg1",
|
||||
SSHURL: "src-ssh-url",
|
||||
DefaultBranch: "master",
|
||||
Owner: &models.User{UserName: "src-org"},
|
||||
Parent: &models.Repository{
|
||||
Name: "pkg1",
|
||||
Owner: &models.User{UserName: "target-org"},
|
||||
},
|
||||
}
|
||||
|
||||
gitea.EXPECT().GetRepository("target-org", "pkg1").Return(targetRepo, nil)
|
||||
// 4. Branch check - missing
|
||||
mockGit.EXPECT().GitClone("pkg1", "", "target-ssh-url").Return("origin", nil)
|
||||
mockGit.EXPECT().GitRemoteHead("pkg1", "origin", "main").Return("", fmt.Errorf("not found"))
|
||||
|
||||
// Orphan branch creation
|
||||
mockGit.EXPECT().GitExecOrPanic("pkg1", "checkout", "--orphan", "main")
|
||||
mockGit.EXPECT().GitExecOrPanic("pkg1", "rm", "-rf", ".")
|
||||
mockGit.EXPECT().GitExecOrPanic("pkg1", "commit", "--allow-empty", "-m", gomock.Any())
|
||||
mockGit.EXPECT().GitExecOrPanic("pkg1", "push", "origin", "main")
|
||||
|
||||
// 5. Source repo fetch
|
||||
gitea.EXPECT().GetRepository("src-org", "pkg1").Return(srcRepo, nil)
|
||||
mockGit.EXPECT().GitExecWithOutput("pkg1", "ls-remote", "--heads", "src-ssh-url", "master").Return("src-sha refs/heads/master", nil)
|
||||
|
||||
// PR creation
|
||||
gitea.EXPECT().CreatePullRequestIfNotExist(targetRepo, "src-org:master", "main", gomock.Any(), gomock.Any()).Return(&models.PullRequest{Index: 456}, nil, false)
|
||||
|
||||
err := ProcessIssue(issue, configs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Config not found", func(t *testing.T) {
|
||||
issueNoConfig := &models.Issue{
|
||||
Title: "[ADD] pkg1",
|
||||
Body: "src-org/pkg1#master",
|
||||
Index: 123,
|
||||
Repository: &models.RepositoryMeta{
|
||||
Owner: "other-org",
|
||||
Name: "other-prj",
|
||||
},
|
||||
Ref: "refs/heads/main",
|
||||
}
|
||||
err := ProcessIssue(issueNoConfig, configs)
|
||||
if err == nil || err.Error() != "Cannot find config for other-org/other-prj#main" {
|
||||
t.Errorf("Expected config not found error, got %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("No repos in body", func(t *testing.T) {
|
||||
mockGitGen := mock_common.NewMockGitHandlerGenerator(ctl)
|
||||
GitHandler = mockGitGen
|
||||
err := ProcessIssue(&models.Issue{
|
||||
Title: "[ADD] pkg1",
|
||||
Body: "nothing here",
|
||||
Ref: "refs/heads/main",
|
||||
Repository: &models.RepositoryMeta{
|
||||
Owner: "test-org",
|
||||
Name: "test-prj",
|
||||
},
|
||||
}, configs)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
)
|
||||
|
||||
func TestSyncPR(t *testing.T) {
|
||||
CurrentUser = &models.User{UserName: "testuser"}
|
||||
config := &common.AutogitConfig{
|
||||
Reviewers: []string{"reviewer1", "reviewer2"},
|
||||
Branch: "testing",
|
||||
@@ -152,3 +151,4 @@ func TestSyncPR(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ func commandsForPackages(dir, prefix string, startN, endN int) [][]string {
|
||||
|
||||
func setupGitForTests(t *testing.T, git *common.GitHandlerImpl) {
|
||||
common.ExtraGitParams = []string{
|
||||
"TZ=UTC",
|
||||
"GIT_CONFIG_COUNT=1",
|
||||
"GIT_CONFIG_KEY_0=protocol.file.allow",
|
||||
"GIT_CONFIG_VALUE_0=always",
|
||||
|
||||
Reference in New Issue
Block a user