copyright

This commit is contained in:
Adam Majer 2024-09-10 18:24:41 +02:00
parent f38b63b297
commit 652ce0d875
33 changed files with 649 additions and 63 deletions

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -10,10 +28,10 @@ import (
) )
type AutogitConfig struct { type AutogitConfig struct {
Workflows []string // [pr, direct, test] Workflows []string // [pr, direct, test]
Organization string Organization string
GitProjectName string // Organization/GitProjectName.git is PrjGit GitProjectName string // Organization/GitProjectName.git is PrjGit
Branch string // branch name of PkgGit that aligns with PrjGit submodules Branch string // branch name of PkgGit that aligns with PrjGit submodules
} }
func ReadWorkflowConfigs(reader io.Reader) ([]*AutogitConfig, error) { func ReadWorkflowConfigs(reader io.Reader) ([]*AutogitConfig, error) {

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
const ( const (
GiteaTokenEnv = "GITEA_TOKEN" GiteaTokenEnv = "GITEA_TOKEN"
ObsUserEnv = "OBS_USER" ObsUserEnv = "OBS_USER"

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
const examplePushJSON = `{ const examplePushJSON = `{
"ref": "refs/heads/main", "ref": "refs/heads/main",
"before": "9fe6b18fee74f49786c39e062ef02bcfb560a0be6eb7851b81954123e2d55629", "before": "9fe6b18fee74f49786c39e062ef02bcfb560a0be6eb7851b81954123e2d55629",
@ -431,7 +449,6 @@ const repoCreateJSON = `{
} }
}` }`
const createBranchJSON = `{ const createBranchJSON = `{
"sha": "691c91e5240f24f5a75393caf8a78826b8a6f9f272ab4faef024102739f0060a", "sha": "691c91e5240f24f5a75393caf8a78826b8a6f9f272ab4faef024102739f0060a",
"ref": "main", "ref": "main",
@ -636,7 +653,7 @@ const createBranchJSON = `{
} }
}` }`
const createTagJSON=`{ const createTagJSON = `{
"sha": "691c91e5240f24f5a75393caf8a78826b8a6f9f272ab4faef024102739f0060a", "sha": "691c91e5240f24f5a75393caf8a78826b8a6f9f272ab4faef024102739f0060a",
"ref": "foobar", "ref": "foobar",
"ref_type": "tag", "ref_type": "tag",
@ -840,7 +857,6 @@ const createTagJSON=`{
} }
}` }`
const createIssueJSON = `{ const createIssueJSON = `{
"action": "opened", "action": "opened",
"number": 1, "number": 1,
@ -1020,7 +1036,6 @@ const createIssueJSON = `{
"commit_id": "" "commit_id": ""
}` }`
const issueAssignJSON = `{ const issueAssignJSON = `{
"action": "unassigned", "action": "unassigned",
"number": 1, "number": 1,
@ -1716,4 +1731,3 @@ const requestedReviewJSON = `{
"commit_id": "", "commit_id": "",
"review": null "review": null
}` }`

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"fmt" "fmt"
"io" "io"

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"os" "os"
"os/exec" "os/exec"

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"fmt" "fmt"
"io" "io"

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
@ -163,7 +181,7 @@ func ProcessEvent(f RequestProcessor, h *RequestHandler) {
if err := f(h); err != nil { if err := f(h); err != nil {
log.Println(err) log.Println(err)
} }
} }
func ProcessRabbitMQEvents(listenDefs ListenDefinitions, orgs []string) error { func ProcessRabbitMQEvents(listenDefs ListenDefinitions, orgs []string) error {

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"fmt" "fmt"
"io" "io"
@ -15,4 +33,3 @@ func CreateStdoutLogger(stdout, stderr io.Writer) (*log.Logger, *log.Logger) {
errLogger := log.New(stderr, idStr, log.Lmsgprefix) errLogger := log.New(stderr, idStr, log.Lmsgprefix)
return stdLogger, errLogger return stdLogger, errLogger
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"bytes" "bytes"
"regexp" "regexp"

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"bytes" "bytes"
"encoding/xml" "encoding/xml"

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"testing" "testing"
) )

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
type CreateWebhookEvent struct { type CreateWebhookEvent struct {
Sha string Sha string
Ref string // name of tag/branch Ref string // name of tag/branch
@ -12,4 +30,3 @@ type CreateWebhookEvent struct {
func (c *CreateWebhookEvent) GetAction() string { func (c *CreateWebhookEvent) GetAction() string {
return c.Ref_type return c.Ref_type
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
type ForkWebhookEvent struct { type ForkWebhookEvent struct {
Forkee *Repository Forkee *Repository
Repository *Repository Repository *Repository
@ -9,4 +27,3 @@ type ForkWebhookEvent struct {
func (*ForkWebhookEvent) GetAction() string { func (*ForkWebhookEvent) GetAction() string {
return "fork" return "fork"
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -74,7 +92,7 @@ type RequestHandler struct {
StdLogger, ErrLogger *log.Logger StdLogger, ErrLogger *log.Logger
Request *Request Request *Request
// Git *GitHandler // Git *GitHandler
} }
func (r *RequestHandler) WriteError() { func (r *RequestHandler) WriteError() {
@ -86,11 +104,11 @@ func CreateRequestHandler() (*RequestHandler, error) {
h.StdLogger, h.ErrLogger = CreateStdoutLogger(os.Stdout, os.Stderr) h.StdLogger, h.ErrLogger = CreateStdoutLogger(os.Stdout, os.Stderr)
/* var err error /* var err error
h.Git, err = CreateGitHandler(git_author, name) h.Git, err = CreateGitHandler(git_author, name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
*/ */
return h, nil return h, nil
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
type IssueDetail struct { type IssueDetail struct {
Id int Id int
Number int Number int
@ -48,4 +66,3 @@ func (i *IssueWebhookEvent) GetAction() string {
func (i *IssueCommentWebhookEvent) GetAction() string { func (i *IssueCommentWebhookEvent) GetAction() string {
return i.Action return i.Action
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -51,14 +69,14 @@ func (p *PullRequestWebhookEvent) GetAction() string {
} }
func (h *RequestHandler) parsePullRequest(data io.Reader) (action *PullRequestWebhookEvent, err error) { func (h *RequestHandler) parsePullRequest(data io.Reader) (action *PullRequestWebhookEvent, err error) {
action=new(PullRequestWebhookEvent) action = new(PullRequestWebhookEvent)
err = json.NewDecoder(data).Decode(&action) err = json.NewDecoder(data).Decode(&action)
if err != nil { if err != nil {
return nil, fmt.Errorf("Got error while parsing json: %w", err) return nil, fmt.Errorf("Got error while parsing json: %w", err)
} }
h.Request = &Request { h.Request = &Request{
Data: action, Data: action,
Type: RequestType_PR, Type: RequestType_PR,
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"os" "os"
"strings" "strings"
@ -661,7 +679,7 @@ const samplePR_JSON = `{
} }
` `
const samplePRsync_JSON=`{ const samplePRsync_JSON = `{
"action": "synchronized", "action": "synchronized",
"number": 1, "number": 1,
"pull_request": { "pull_request": {

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -40,7 +58,7 @@ func (h *RequestHandler) parsePushRequest(data io.Reader) (*PushWebhookEvent, er
} }
h.StdLogger.Printf("Request push for repo: %s\n", action.Repository.Full_Name) h.StdLogger.Printf("Request push for repo: %s\n", action.Repository.Full_Name)
h.Request = &Request { h.Request = &Request{
Type: RequestType_Push, Type: RequestType_Push,
Data: action, Data: action,
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"os" "os"
"strings" "strings"

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
type ReleaseWebhookDetail struct { type ReleaseWebhookDetail struct {
Tag_name string Tag_name string
Name string Name string

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -64,7 +82,7 @@ func (h *RequestHandler) parseRepositoryRequest(dataReader io.Reader) (data *Rep
return nil, fmt.Errorf("Request has no data.... skipping") return nil, fmt.Errorf("Request has no data.... skipping")
} }
h.Request = &Request { h.Request = &Request{
Data: data, Data: data,
Type: RequestType_Repository, Type: RequestType_Repository,
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"os" "os"
"strings" "strings"
@ -15,7 +33,6 @@ func (s *testLogger) WriteString(str2 string) (int, error) {
return len(s.str), nil return len(s.str), nil
} }
func TestRepositoryRequestParsing(t *testing.T) { func TestRepositoryRequestParsing(t *testing.T) {
t.Run("parsing repo creation message", func(t *testing.T) { t.Run("parsing repo creation message", func(t *testing.T) {
var h RequestHandler var h RequestHandler

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
type WikiWebhookEvent struct { type WikiWebhookEvent struct {
Action string Action string
Page string Page string
@ -9,7 +27,6 @@ type WikiWebhookEvent struct {
Sender User Sender User
} }
func (w *WikiWebhookEvent) GetAction() string { func (w *WikiWebhookEvent) GetAction() string {
return w.Action return w.Action
} }

View File

@ -1,5 +1,23 @@
package common package common
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"errors" "errors"
"fmt" "fmt"

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"errors" "errors"
"flag" "flag"

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"encoding/json" "encoding/json"
"flag" "flag"

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"context" "context"
"crypto/tls" "crypto/tls"
@ -43,7 +61,7 @@ func PublishMessage(giteaOrg, giteaWebhookType, action string, data []byte) erro
} }
} else { } else {
msg = Message{ msg = Message{
Topic: fmt.Sprintf("%s.%s.%s.%s", topicScope, common.TopicApp, giteaOrg, giteaWebhookType), Topic: fmt.Sprintf("%s.%s.%s.%s", topicScope, common.TopicApp, giteaOrg, giteaWebhookType),
Body: data, Body: data,
} }
} }

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"bytes" "bytes"
"errors" "errors"

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
@ -97,7 +115,7 @@ func ProcessingObsMessages(host, username, password, queueName string) {
if obsNotifications == nil { if obsNotifications == nil {
obsNotifications = make(map[string]*BuildNotification) obsNotifications = make(map[string]*BuildNotification)
// notificationChannels = make(map[string]chan *BuildNotification) // notificationChannels = make(map[string]chan *BuildNotification)
} }
auth := "" auth := ""

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"fmt" "fmt"
"log" "log"
@ -22,28 +40,30 @@ type BuildStatusCacheItem struct {
var obs *common.ObsClient var obs *common.ObsClient
var buildStatusCache map[string]BuildStatusCacheItem var buildStatusCache map[string]BuildStatusCacheItem
/*
func CacheBuildStatus(prj, pkg string) ([]common.BuildResult, error) {
list, err := obs.BuildStatus(prj, pkg)
if err != nil {
return nil, err
}
return /*
} func CacheBuildStatus(prj, pkg string) ([]common.BuildResult, error) {
list, err := obs.BuildStatus(prj, pkg)
if err != nil {
return nil, err
}
return
}
*/ */
func PackageBuildStatus(prj, pkg string) (common.ObsBuildStatusDetail, error) { func PackageBuildStatus(prj, pkg string) (common.ObsBuildStatusDetail, error) {
return common.ObsBuildStatusDetail { return common.ObsBuildStatusDetail{
Code: "succeeded", Code: "succeeded",
Description: "stuff", Description: "stuff",
Success: true, Success: true,
Finished: true, Finished: true,
}, nil }, nil
} }
/* /*
func PackageStatusSvg(buildStatus []common.ObsBuildStatusDetail) []byte { func PackageStatusSvg(buildStatus []common.ObsBuildStatusDetail) []byte {
return return
} }
*/ */
func PackageStatusSummarySvg(buildStatus common.ObsBuildStatusDetail) []byte { func PackageStatusSummarySvg(buildStatus common.ObsBuildStatusDetail) []byte {
fillColor := "orange" fillColor := "orange"
@ -74,9 +94,9 @@ func main() {
log.Fatal("OBS_HOSTNAME env required.") log.Fatal("OBS_HOSTNAME env required.")
} }
/* /*
if obs, err := common.NewObsClient(obsHost); err != nil { if obs, err := common.NewObsClient(obsHost); err != nil {
log.Fatal(err) log.Fatal(err)
} }
*/ */
http.HandleFunc("GET /{ObsProject}", func(res http.ResponseWriter, req *http.Request) { http.HandleFunc("GET /{ObsProject}", func(res http.ResponseWriter, req *http.Request) {

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"crypto/tls" "crypto/tls"
"encoding/json" "encoding/json"
@ -120,15 +138,15 @@ func ProcessingObsMessages(host, username, password, queueName string) {
}() }()
var err error var err error
out, err = os.OpenFile("messages.txt", os.O_WRONLY | os.O_APPEND, 0644) out, err = os.OpenFile("messages.txt", os.O_WRONLY|os.O_APPEND, 0644)
if err != nil { if err != nil {
log.Printf("Cannot open message.txt: %v", err) log.Printf("Cannot open message.txt: %v", err)
return return
} }
if obsNotifications == nil { if obsNotifications == nil {
obsNotifications = make(map[string]*BuildNotification) obsNotifications = make(map[string]*BuildNotification)
// notificationChannels = make(map[string]chan *BuildNotification) // notificationChannels = make(map[string]chan *BuildNotification)
} }
auth := "" auth := ""

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"fmt" "fmt"
"os" "os"
@ -34,21 +52,21 @@ func fetchPrGit(h *common.RequestHandler, pr *models.PullRequest) error {
func processPullRequestClosed(h *common.RequestHandler) error { func processPullRequestClosed(h *common.RequestHandler) error {
// this needs to be moved to pull merger // this needs to be moved to pull merger
return nil return nil
/* /*
req := h.Data.(*common.PullRequestAction) req := h.Data.(*common.PullRequestAction)
if req.Repository.Name != common.DefaultGitPrj {
// we only handle project git PR updates here
return nil
}
if req.Repository.Name != common.DefaultGitPrj {
// we only handle project git PR updates here
return nil
}
if err := fetchPrGit(h, req.Pull_Request); err != nil { if err := fetchPrGit(h, req.Pull_Request); err != nil {
return err return err
} }
headSubmodules := h.GitSubmoduleList(dir, pr.Head.Sha)
baseSubmodules := h.GitSubmoduleList(dir, pr.Base.Sha) headSubmodules := h.GitSubmoduleList(dir, pr.Head.Sha)
return nil baseSubmodules := h.GitSubmoduleList(dir, pr.Base.Sha)
return nil
*/ */
} }

View File

@ -1,5 +1,23 @@
package main package main
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import ( import (
"flag" "flag"
"fmt" "fmt"