You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/07/29 15:40:55 UTC

[incubator-devlake] branch main updated (66c0f9d3 -> d83b925a)

This is an automated email from the ASF dual-hosted git repository.

warren pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


    from 66c0f9d3 feat: project_mapping for org plugin (#2616)
     new f77ce89f fix: casting error in FolderInput node struct
     new d83b925a fix: add asf headers

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 plugins/helper/list.go                             | 11 ++++--
 plugins/helper/queue.go                            |  8 +++--
 .../e2e/commit_test.go => helper/queue_test.go}    | 27 ++++++++------
 plugins/jenkins/models/job.go                      |  4 +++
 .../connection.go => jenkins/models/job_test.go}   | 42 +++++++++-------------
 5 files changed, 52 insertions(+), 40 deletions(-)
 copy plugins/{github/e2e/commit_test.go => helper/queue_test.go} (59%)
 copy plugins/{jira/models/connection.go => jenkins/models/job_test.go} (61%)


[incubator-devlake] 02/02: fix: add asf headers

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit d83b925a82fc756a8b2677ff94e50868db63a669
Author: Keon Amini <ke...@merico.dev>
AuthorDate: Fri Jul 29 10:30:03 2022 -0500

    fix: add asf headers
---
 plugins/helper/queue_test.go       | 17 +++++++++++++++++
 plugins/jenkins/models/job.go      |  1 -
 plugins/jenkins/models/job_test.go | 17 +++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/plugins/helper/queue_test.go b/plugins/helper/queue_test.go
index 519f0ecb..8855ce95 100644
--- a/plugins/helper/queue_test.go
+++ b/plugins/helper/queue_test.go
@@ -1,3 +1,20 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package helper
 
 import (
diff --git a/plugins/jenkins/models/job.go b/plugins/jenkins/models/job.go
index 904f62d6..43687ce2 100644
--- a/plugins/jenkins/models/job.go
+++ b/plugins/jenkins/models/job.go
@@ -49,7 +49,6 @@ type FolderInput struct {
 }
 
 func (f *FolderInput) Data() interface{} {
-	// default implementation
 	return f.Path
 }
 
diff --git a/plugins/jenkins/models/job_test.go b/plugins/jenkins/models/job_test.go
index 7388bc29..12721640 100644
--- a/plugins/jenkins/models/job_test.go
+++ b/plugins/jenkins/models/job_test.go
@@ -1,3 +1,20 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package models
 
 import (


[incubator-devlake] 01/02: fix: casting error in FolderInput node struct

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit f77ce89fe1e8d13e5e46a8c907c880164121bcef
Author: Keon Amini <ke...@merico.dev>
AuthorDate: Fri Jul 29 10:25:37 2022 -0500

    fix: casting error in FolderInput node struct
---
 plugins/helper/list.go             | 11 ++++++++---
 plugins/helper/queue.go            |  8 ++++++--
 plugins/helper/queue_test.go       | 23 +++++++++++++++++++++++
 plugins/jenkins/models/job.go      |  5 +++++
 plugins/jenkins/models/job_test.go | 24 ++++++++++++++++++++++++
 5 files changed, 66 insertions(+), 5 deletions(-)

diff --git a/plugins/helper/list.go b/plugins/helper/list.go
index a130bfa2..c0f507e5 100644
--- a/plugins/helper/list.go
+++ b/plugins/helper/list.go
@@ -19,11 +19,12 @@ package helper
 
 // ListBaseNode 'abstract' base struct for Nodes that are chained in a linked list manner
 type ListBaseNode struct {
-	next *ListBaseNode
+	next QueueNode
 }
 
 func (l *ListBaseNode) Data() interface{} {
-	panic("list node Data() needs to be implemented by subclasses")
+	// default implementation
+	return nil
 }
 
 func (l *ListBaseNode) Next() interface{} {
@@ -34,7 +35,11 @@ func (l *ListBaseNode) Next() interface{} {
 }
 
 func (l *ListBaseNode) SetNext(next interface{}) {
-	l.next = next.(*ListBaseNode)
+	if next == nil {
+		l.next = nil
+	} else {
+		l.next = next.(QueueNode)
+	}
 }
 
 // NewListBaseNode create and init a new node (only to be called by subclasses)
diff --git a/plugins/helper/queue.go b/plugins/helper/queue.go
index edf58d62..4dd18e92 100644
--- a/plugins/helper/queue.go
+++ b/plugins/helper/queue.go
@@ -128,7 +128,7 @@ func NewQueue() *Queue {
 }
 
 type QueueIteratorNode struct {
-	next *QueueIteratorNode
+	next QueueNode
 	data interface{}
 }
 
@@ -140,7 +140,11 @@ func (q *QueueIteratorNode) Next() interface{} {
 }
 
 func (q *QueueIteratorNode) SetNext(next interface{}) {
-	q.next, _ = next.(*QueueIteratorNode)
+	if next == nil {
+		q.next = nil
+	} else {
+		q.next, _ = next.(QueueNode)
+	}
 }
 
 func (q *QueueIteratorNode) Data() interface{} {
diff --git a/plugins/helper/queue_test.go b/plugins/helper/queue_test.go
new file mode 100644
index 00000000..519f0ecb
--- /dev/null
+++ b/plugins/helper/queue_test.go
@@ -0,0 +1,23 @@
+package helper
+
+import (
+	"github.com/stretchr/testify/require"
+	"testing"
+)
+
+func TestQueue(t *testing.T) {
+	it := NewQueueIterator()
+	it.Push(NewQueueIteratorNode("a"))
+	it.Push(NewQueueIteratorNode("b"))
+	require.True(t, it.HasNext())
+	folderRaw, err := it.Fetch()
+	require.NoError(t, err)
+	node := folderRaw.(*QueueIteratorNode)
+	require.Equal(t, "a", node.Data())
+	require.True(t, it.HasNext())
+	folderRaw, err = it.Fetch()
+	require.NoError(t, err)
+	node = folderRaw.(*QueueIteratorNode)
+	require.Equal(t, "b", node.Data())
+	require.False(t, it.HasNext())
+}
diff --git a/plugins/jenkins/models/job.go b/plugins/jenkins/models/job.go
index 0a406999..904f62d6 100644
--- a/plugins/jenkins/models/job.go
+++ b/plugins/jenkins/models/job.go
@@ -48,6 +48,11 @@ type FolderInput struct {
 	Path string
 }
 
+func (f *FolderInput) Data() interface{} {
+	// default implementation
+	return f.Path
+}
+
 func NewFolderInput(path string) *FolderInput {
 	return &FolderInput{
 		Path:         path,
diff --git a/plugins/jenkins/models/job_test.go b/plugins/jenkins/models/job_test.go
new file mode 100644
index 00000000..7388bc29
--- /dev/null
+++ b/plugins/jenkins/models/job_test.go
@@ -0,0 +1,24 @@
+package models
+
+import (
+	"github.com/apache/incubator-devlake/plugins/helper"
+	"github.com/stretchr/testify/require"
+	"testing"
+)
+
+func TestFolderInput(t *testing.T) {
+	it := helper.NewQueueIterator()
+	it.Push(NewFolderInput("a"))
+	it.Push(NewFolderInput("b"))
+	require.True(t, it.HasNext())
+	folderRaw, err := it.Fetch()
+	require.NoError(t, err)
+	folder := folderRaw.(*FolderInput)
+	require.Equal(t, "a", folder.Data())
+	require.True(t, it.HasNext())
+	folderRaw, err = it.Fetch()
+	require.NoError(t, err)
+	folder = folderRaw.(*FolderInput)
+	require.Equal(t, "b", folder.Data())
+	require.False(t, it.HasNext())
+}