From 79a87af49ded61391865531fc80bff19e46e3339 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Fri, 4 Feb 2022 09:22:45 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20use=20date=20a?= =?UTF-8?q?s=20release=20name,=20optimize=20a=20minor=20piece=20of=20code?= =?UTF-8?q?=20in=20OSS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/workflow.yaml | 8 ++++++-- oss/oss.go | 16 ++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 4b80d2598..916446193 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -11,6 +11,9 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: set env + run: echo "NOW=v$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV + - uses: actions/checkout@v2 - name: Set up Go @@ -18,6 +21,7 @@ jobs: with: go-version: 1.17 + - name: Build run: | mkdir -p output @@ -68,8 +72,8 @@ jobs: if: ${{ !env.ACT }} with: repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" + automatic_release_tag: "${{ env.NOW }}" prerelease: false - title: "${{ github.sha }}" + title: "${{ env.NOW }}" files: | output/* diff --git a/oss/oss.go b/oss/oss.go index d6e9b27f0..0f5b839ab 100644 --- a/oss/oss.go +++ b/oss/oss.go @@ -137,16 +137,16 @@ func findRange(issue ossIssue, doc sglsp.TextDocumentItem) sglsp.Range { lines := strings.Split( strings.ReplaceAll(doc.Text, "\r", ""), "\n") + var packageName string + if len(issue.From) > 1 { + split := strings.Split(issue.From[1], "@") + packageName = fmt.Sprintf("\"%s\": \"", split[0]) + } else { + packageName = fmt.Sprintf("\"%s\": \"", issue.Name) + } var lineStart, lineEnd, characterStart, characterEnd int for i := 0; i < len(lines); i++ { line := lines[i] - var packageName string - if len(issue.From) > 1 { - split := strings.Split(issue.From[1], "@") - packageName = fmt.Sprintf("\"%s\": \"", split[0]) - } else { - packageName = fmt.Sprintf("\"%s\": \"", issue.Name) - } if issue.PackageManager == "npm" { if strings.HasPrefix( strings.TrimSpace(strings.ReplaceAll(line, "^", "")), packageName) { @@ -157,7 +157,7 @@ func findRange(issue ossIssue, doc sglsp.TextDocumentItem) sglsp.Range { break } else if issue.PackageManager == "maven" { // todo respect from - packageName = strings.Split(strings.ReplaceAll(packageName, "\"", ""), ":")[0] + packageName = strings.Split(strings.ReplaceAll(packageName, "\"", ""), ":")[1] if filepath.Base(string(doc.URI)) == "pom.xml" && strings.Contains( line, fmt.Sprintf("%s", packageName),