mirror of https://github.com/harness/drone.git
fix for branch create in empty repo, minor config changes for err shadow
parent
75ec201c2b
commit
e38b0ebc65
|
@ -297,6 +297,8 @@ issues:
|
|||
max-same-issues: 50
|
||||
|
||||
exclude-rules:
|
||||
- text: 'shadow: declaration of "err" shadows declaration at'
|
||||
linters: [ govet ]
|
||||
- source: "^//\\s*go:generate\\s"
|
||||
linters: [ lll ]
|
||||
- source: "(noinspection|TODO)"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceFolder}",
|
||||
"program": "cmd/gitness",
|
||||
"args": ["server", "../../.local.env"]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -7,7 +7,6 @@ package gitrpc
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/harness/gitness/gitrpc/rpc"
|
||||
|
@ -31,19 +30,19 @@ func (params *BlameParams) Validate() error {
|
|||
}
|
||||
|
||||
if params.GitRef == "" {
|
||||
return fmt.Errorf("git ref needs to be provided: %w", ErrInvalidArgument)
|
||||
return Errorf(StatusInvalidArgument, "git ref needs to be provided")
|
||||
}
|
||||
|
||||
if params.Path == "" {
|
||||
return fmt.Errorf("file path needs to be provided: %w", ErrInvalidArgument)
|
||||
return Errorf(StatusInvalidArgument, "file path needs to be provided")
|
||||
}
|
||||
|
||||
if params.LineFrom < 0 || params.LineTo < 0 {
|
||||
return fmt.Errorf("line from and line to can't be negative: %w", ErrInvalidArgument)
|
||||
return Errorf(StatusInvalidArgument, "line from and line to can't be negative")
|
||||
}
|
||||
|
||||
if params.LineTo > 0 && params.LineFrom > params.LineTo {
|
||||
return fmt.Errorf("line from can't be after line after: %w", ErrInvalidArgument)
|
||||
return Errorf(StatusInvalidArgument, "line from can't be after line after")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -36,6 +36,10 @@ func (s ReferenceService) CreateBranch(ctx context.Context,
|
|||
return nil, processGitErrorf(err, "failed to open repo")
|
||||
}
|
||||
|
||||
if ok, err := repo.IsEmpty(); ok {
|
||||
return nil, ErrInvalidArgumentf("branch cannot be created on empty repository", err)
|
||||
}
|
||||
|
||||
sharedRepo, err := NewSharedRepo(s.tmpDir, base.GetRepoUid(), repo)
|
||||
if err != nil {
|
||||
return nil, processGitErrorf(err, "failed to create new shared repo")
|
||||
|
|
|
@ -64,6 +64,9 @@ func Errorf(code codes.Code, format string, args ...any) (err error) {
|
|||
newargs := make([]any, 0, len(args))
|
||||
|
||||
for _, arg := range args {
|
||||
if arg == nil {
|
||||
continue
|
||||
}
|
||||
switch t := arg.(type) {
|
||||
case error:
|
||||
err = t
|
||||
|
|
Loading…
Reference in New Issue