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 2d19b39b8ded3f7bf4df190153aa4403aef23cd9
Author: Nddtfjiang <[email protected]>
AuthorDate: Tue Jun 7 09:43:57 2022 +0000

    fix: fix an error lost before directrun
    
    Add tagsPattern document to readme
    Remove an unuse link in readme.
    Add some comment
    fix an error lost before DirectRun on refdiff.
    
    Nddtfjiang <[email protected]>
---
 plugins/refdiff/README.md                          | 28 +++++++++++++++++-----
 plugins/refdiff/refdiff.go                         |  5 +++-
 .../refdiff/tasks/ref_commit_diff_calculator.go    |  1 +
 plugins/refdiff/tasks/ref_issue_diff_calculator.go |  1 +
 plugins/refdiff/tasks/refdiff_task_data.go         |  7 +++---
 5 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/plugins/refdiff/README.md b/plugins/refdiff/README.md
index 01f649e3..3c065aea 100644
--- a/plugins/refdiff/README.md
+++ b/plugins/refdiff/README.md
@@ -1,10 +1,4 @@
 # RefDiff
-
-
-| [English](README.md) | [中文](README-zh-CN.md) |
-| --- | --- |
-
-
 ## Summary
 
 For development workload analysis, we often need to know how many commits have 
been created between 2 releases. This plugin offers the ability to calculate 
the commits of difference between 2 Ref(branch/tag), and the result will be 
stored back into database for further analysis.
@@ -90,6 +84,28 @@ and if you want to perform certain subtasks.
   ]
 ]
 ```
+Or you can use tagsPattern to match the tags you want
+And you can use tagOrder (support `alphabetically` and `reverse 
alphabetically`) to set the order rule with tagLimit to limit the count of 
matching.
+This is support to calculateCommitsDiff and calculateIssuesDiff
+```json
+[
+  [
+    {
+      "plugin": "refdiff",
+      "subtasks": [
+        "calculateCommitsDiff",
+        "calculateIssuesDiff",
+      ],
+      "options": {
+        "repoId": "github:GithubRepo:384111310",
+        "tagsPattern":".*\\.11\\..*",
+        "tagLimit":3,
+        "tagOrder":"reverse alphabetically",
+      }
+    }
+  ]
+]
+```
 
 2. Curl Mode:
 ```
diff --git a/plugins/refdiff/refdiff.go b/plugins/refdiff/refdiff.go
index 9cfaa1f8..c9c3b9d0 100644
--- a/plugins/refdiff/refdiff.go
+++ b/plugins/refdiff/refdiff.go
@@ -94,7 +94,10 @@ func main() {
        //_ = refdiffCmd.MarkFlagRequired("old-ref")
 
        refdiffCmd.Run = func(cmd *cobra.Command, args []string) {
-               tl, _ := strconv.Atoi(*tagsLimit)
+               tl, err := strconv.Atoi(*tagsLimit)
+               if err != nil {
+                       panic(err)
+               }
                pairs := make([]map[string]string, 0, 1)
                if *newRef == "" && *oldRef == "" {
                        if *tagsPattern == "" {
diff --git a/plugins/refdiff/tasks/ref_commit_diff_calculator.go 
b/plugins/refdiff/tasks/ref_commit_diff_calculator.go
index 69adb46f..420ed963 100644
--- a/plugins/refdiff/tasks/ref_commit_diff_calculator.go
+++ b/plugins/refdiff/tasks/ref_commit_diff_calculator.go
@@ -27,6 +27,7 @@ import (
        "gorm.io/gorm/clause"
 )
 
+// Calculate the commits pairs both from Options.Pairs and TagPattern
 func CalculateCommitsPairs(taskCtx core.SubTaskContext) ([][4]string, error) {
        data := taskCtx.GetData().(*RefdiffTaskData)
        repoId := data.Options.RepoId
diff --git a/plugins/refdiff/tasks/ref_issue_diff_calculator.go 
b/plugins/refdiff/tasks/ref_issue_diff_calculator.go
index 3a80482d..5b9d92a7 100644
--- a/plugins/refdiff/tasks/ref_issue_diff_calculator.go
+++ b/plugins/refdiff/tasks/ref_issue_diff_calculator.go
@@ -26,6 +26,7 @@ import (
        "github.com/apache/incubator-devlake/plugins/helper"
 )
 
+// Calculate the pair list both from Options.Pairs and TagPattern
 func CaculatePairList(taskCtx core.SubTaskContext) ([][2]string, error) {
        data := taskCtx.GetData().(*RefdiffTaskData)
        repoId := data.Options.RepoId
diff --git a/plugins/refdiff/tasks/refdiff_task_data.go 
b/plugins/refdiff/tasks/refdiff_task_data.go
index c2b364fc..648f671e 100644
--- a/plugins/refdiff/tasks/refdiff_task_data.go
+++ b/plugins/refdiff/tasks/refdiff_task_data.go
@@ -32,9 +32,9 @@ type RefdiffOptions struct {
        Tasks  []string `json:"tasks,omitempty"`
        Pairs  []RefPair
 
-       TagsPattern string
-       TagsLimit   int
-       TagsOrder   string
+       TagsPattern string // The Pattern to match from all tags
+       TagsLimit   int    // How many tags be matched should be used.
+       TagsOrder   string // The Rule to Order the tag list
 }
 
 type RefdiffTaskData struct {
@@ -79,6 +79,7 @@ func (rs RefsReverseAlphabetically) Swap(i, j int) {
        rs[i], rs[j] = rs[j], rs[i]
 }
 
+// Calculate the TagPattern order by tagsOrder and return the Refs
 func CaculateTagPattern(taskCtx core.SubTaskContext) (Refs, error) {
        rs := Refs{}
        data := taskCtx.GetData().(*RefdiffTaskData)

Reply via email to