Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: xztaityozx/go-cdx
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.13
Choose a base ref
...
head repository: xztaityozx/go-cdx
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 2,011 additions and 880 deletions.
  1. +197 −0 .github/workflows/go.yml
  2. +8 −0 .idea/dictionaries/xztaityozx.xml
  3. +8 −0 .idea/go-cdx.iml
  4. +20 −0 .idea/inspectionProfiles/Project_Default.xml
  5. +6 −0 .idea/misc.xml
  6. +8 −0 .idea/modules.xml
  7. +6 −0 .idea/vcs.xml
  8. +514 −0 .idea/workspace.xml
  9. +1 −2 .travis.yml
  10. +6 −6 LICENSE
  11. +39 −171 README.md
  12. +86 −0 cd/cd.go
  13. +24 −0 cd/cd_test.go
  14. +0 −48 cmd/cd.go
  15. +0 −109 cmd/cd_test.go
  16. +0 −52 cmd/config.go
  17. +0 −126 cmd/file.go
  18. +0 −146 cmd/file_test.go
  19. +0 −25 cmd/init.go
  20. +0 −24 cmd/log.go
  21. +97 −110 cmd/root.go
  22. +0 −24 cmd/root_test.go
  23. +0 −36 cmd/version.go
  24. +93 −0 config/config.go
  25. +27 −0 config/fuzzyfinder.go
  26. +173 −0 config/source.go
  27. +40 −0 config/source_test.go
  28. +30 −0 fileutil/append.go
  29. +31 −0 fileutil/append_test.go
  30. +35 −0 go.mod
  31. +338 −0 go.sum
  32. BIN img/cdx_c_g.png
  33. +1 −1 main.go
  34. +94 −0 subcmd/subcmd.go
  35. +129 −0 subcmd/subcmd_test.go
197 changes: 197 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: Go

on:
push:
paths:
- '**.go'
- '.github/workflows/**'
pull_request:
paths:
- '**.go'
- '.github/workflows/**'

jobs:
linter:
name: "golang-linter"
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.17
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.43
skip-go-installation: true

test:
name: Unit Test
needs: [linter]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
- name: before cache
run: |
mkdir -p ~/go/pkg/mod
- uses: actions/cache@v2.1.2
id: cache-go
with:
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
path: ~/go/pkg/mod
restore-keys: |
go-${{ matrix.os }}-
- name: Setup GoLang
uses: actions/setup-go@v3
with:
go-version: ^1.17
- name: Get Dependencies
if: steps.cache-go.outputs.cache-hit != 'true'
run: go get -v -t -d ./...

- name: Test
run: |
go test -v ./...
build:
name: Build release binary
runs-on: ${{ matrix.os }}
needs: [linter, test]
if: contains(github.ref, 'tags/v')
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2.3.3
- name: before cache
run: |
mkdir -p ~/go/pkg/mod
- uses: actions/cache@v2.1.2
id: cache-go
with:
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
path: ~/go/pkg/mod
restore-keys: |
go-${{ matrix.os }}-
- name: Setup GoLang
uses: actions/setup-go@v2.1.3
with:
go-version: ^1.17
- name: Get Dependencies
if: steps.cache-go.outputs.cache-hit != 'true'
run: go get -v -t -d ./...

- name: vars
id: vars
shell: bash
run: |
echo ::set-output name=os::"$(echo ${{ matrix.os }} | sed 's/-latest//g;s/ubuntu/linux/g')"
echo ::set-output name=version::${TAG_REF_NAME##*/v}
env:
TAG_REF_NAME: ${{ github.ref }}


- name: Build
run: |
mkdir ./${{ steps.vars.outputs.os }}
go build -v -o ${{ steps.vars.outputs.os }}/go-cdx
- name: Create completion script
shell: bash
working-directory: ${{ steps.vars.outputs.os }}
run: |
mkdir -p $HOME/.config/go-cdx
touch $HOME/.config/go-cdx/go-cdx.yaml
[[ "${{ matrix.os }}" != "windows-latest" ]] && {
./go-cdx --completion zsh - > ./cdx-completion.zsh
./go-cdx --completion bash - > ./cdx-completion.bash
./go-cdx --completion fish - > ./cdx-completion.fish
}
./go-cdx --completion PowerShell - > ./cdx-completion.ps1
- name: Upload artifact
uses: actions/upload-artifact@v2.2.0
with:
name: ${{ steps.vars.outputs.os }}
path: ./${{ steps.vars.outputs.os }}

create-release:
needs: [linter, test, build]
if: contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
steps:
- name: vars
id: vars
run: |
echo ::set-output name=version::${TAG_REF_NAME##*/v}
env:
TAG_REF_NAME: ${{ github.ref }}

- name: Create Release
uses: actions/create-release@v1.1.4
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vars.outputs.version }}
release_name: Release ${{ steps.vars.outputs.version }}
draft: false
prerelease: false

- name: Output release url
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt

- name: Save Release URL File for publish
uses: actions/upload-artifact@v2.2.0
with:
name: release_url
path: release_url.txt

upload-release:
runs-on: ubuntu-latest
if: contains(github.ref, 'tags/v')
needs: [linter, create-release, test, build]
strategy:
matrix:
os: [linux, windows, macOS]
steps:
- uses: actions/download-artifact@v2.0.5
with:
name: ${{ matrix.os }}
path: ${{ matrix.os }}

- uses: actions/download-artifact@v2.0.5
with:
name: release_url

- name: Get Release Info
id: get_release_info
shell: bash
run: |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v}
echo ::set-output name=upload_url::"$(cat release_url.txt)"
echo ::set-output name=version::${TAG_REF_NAME##*/v}
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}

- name: Create Zip
shell: bash
run: |
zip -r ${{ matrix.os }} ${{ matrix.os }}
- name: Upload assets to GitHub Release
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ./${{ matrix.os }}.zip
asset_name: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.os }}.zip
asset_content_type: application/zip
8 changes: 8 additions & 0 deletions .idea/dictionaries/xztaityozx.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/go-cdx.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading