diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..0f55c3a --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,93 @@ +name: Pr workflow + +on: + push: + branches: + - main + paths-ignore: + - "**/*.go" + - "go.mod" + - "go.sum" + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: '>=1.22' + check-latest: true + + - name: Golangci-lint + uses: golangci/golangci-lint-action@v6.0.1 + + audit: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Verify dependencies + run: go mod verify + + - name: Build + run: go build -v ./... + + - name: Run go vet + run: go vet ./... + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... + + - name: Install golint + run: go install golang.org/x/lint/golint@latest + + - name: Run golint + run: golint ./... + + - name: Run tests + run: go test -race -vet=off ./... + + + test: + runs-on: ubuntu-latest + steps: + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: go + queries: security-and-quality + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + + greetings: + runs-on: ubuntu-latest + steps: + - name: Greeting to the Contributors + run: | + echo "Hello, contributors! Thank you for your hard work and dedication. Your contributions are greatly appreciated!" + echo "Keep up the great work!" + echo "Best regards," + echo "The Team" + + + + + \ No newline at end of file diff --git a/cmd/program/search.go b/cmd/program/search.go new file mode 100644 index 0000000..45242b9 --- /dev/null +++ b/cmd/program/search.go @@ -0,0 +1,34 @@ +package program + +import( + "fmt" + "github.com/go-git/go-git/v5" +) + +type Error struct { + Messafe string +} + +func (e*Error) Error() string { + return fmt.Sprintf("Error: %s", e.Messafe) +} + +func Search(args[]string) (string,error) { + searchTerm := args[0] + option := ["-un", "-nt", "-np"] + if len(args) == 0 { + return "", &Error{Messafe: "No search term provided"} + } + + switch option { + case "-un": + repos,err := git.PlainOpen(".") + if err != nil { + return "", &Error{Messafe: "Failed to open git repository"} + } + } + if err:= &Error{Messafe: "Not implemented"}; err != nil { + return "", err + } + +} \ No newline at end of file diff --git a/go.mod b/go.mod index 89b50fd..54c1f22 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module github.com/bupd/git-donkey -go 1.23.0 +go 1.23 + require ( github.com/charmbracelet/bubbles v0.21.0