Skip to content

Commit

Permalink
Fixup int to string
Browse files Browse the repository at this point in the history
Resolves this issue after upgrade to go 1.14:
server/events/db/boltdb.go:150:87: conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)

Update hook calls to methods whose signature has changed

Disabled Dockerfile.dev, currently broken on upstream
  • Loading branch information
dyson authored and ddumitrache committed Jan 27, 2023
1 parent cc9080d commit 812d481
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
- redis
build:
context: .
dockerfile: Dockerfile.dev
dockerfile: _Dockerfile.dev
ports:
- 4141:4141
volumes:
Expand All @@ -37,4 +37,4 @@ services:

volumes:
redis:
driver: local
driver: local
2 changes: 1 addition & 1 deletion server/core/db/boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (b *BoltDB) List() ([]models.ProjectLock, error) {
for k, v := range locksBytes {
var lock models.ProjectLock
if err := json.Unmarshal(v, &lock); err != nil {
return locks, errors.Wrap(err, fmt.Sprintf("failed to deserialize lock at key '%d'", k))
return locks, errors.Wrap(err, fmt.Sprintf("failed to deserialize lock at key %q", fmt.Sprint(k)))
}
locks = append(locks, lock)
}
Expand Down
2 changes: 1 addition & 1 deletion server/events/post_workflow_hooks_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (w *DefaultPostWorkflowHooksCommandRunner) RunPostHooks(
log.Debug("got workspace lock")
defer unlockFn()

repoDir, _, err := w.WorkingDir.Clone(log, headRepo, pull, DefaultWorkspace)
repoDir, _, err := w.WorkingDir.Clone(log, headRepo, pull, DefaultWorkspace, []string{})
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion server/events/pre_workflow_hooks_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (w *DefaultPreWorkflowHooksCommandRunner) RunPreHooks(ctx *command.Context,
log.Debug("got workspace lock")
defer unlockFn()

repoDir, _, err := w.WorkingDir.Clone(log, headRepo, pull, DefaultWorkspace)
repoDir, _, err := w.WorkingDir.Clone(log, headRepo, pull, DefaultWorkspace, []string{})
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions server/events/project_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (p *DefaultProjectCommandRunner) doVersion(ctx command.ProjectContext) (ver

func (p *DefaultProjectCommandRunner) doImport(ctx command.ProjectContext) (out *models.ImportSuccess, failure string, err error) {
// Clone is idempotent so okay to run even if the repo was already cloned.
repoDir, _, cloneErr := p.WorkingDir.Clone(ctx.Log, ctx.HeadRepo, ctx.Pull, ctx.Workspace)
repoDir, _, cloneErr := p.WorkingDir.Clone(ctx.Log, ctx.HeadRepo, ctx.Pull, ctx.Workspace, []string{})
if cloneErr != nil {
return nil, "", cloneErr
}
Expand Down Expand Up @@ -568,7 +568,7 @@ func (p *DefaultProjectCommandRunner) doImport(ctx command.ProjectContext) (out

func (p *DefaultProjectCommandRunner) doStateRm(ctx command.ProjectContext) (out *models.StateRmSuccess, failure string, err error) {
// Clone is idempotent so okay to run even if the repo was already cloned.
repoDir, _, cloneErr := p.WorkingDir.Clone(ctx.Log, ctx.HeadRepo, ctx.Pull, ctx.Workspace)
repoDir, _, cloneErr := p.WorkingDir.Clone(ctx.Log, ctx.HeadRepo, ctx.Pull, ctx.Workspace, []string{})
if cloneErr != nil {
return nil, "", cloneErr
}
Expand Down
6 changes: 3 additions & 3 deletions server/events/working_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func (w *FileWorkspace) Clone(
}
}

return cloneDir, w.warnDiverged(log, cloneDir), nil
return cloneDir, w.warnDiverged(log, p, headRepo, cloneDir), nil
}

// alreadyClonedHEAD determines whether the HEAD commit is already present in the cloneDir
// repository. This can be used to determine whether we should force clone again.
func (w *FileWorkspace) alreadyClonedHEAD(log *logging.SimpleLogging, cloneDir string, p models.PullRequest) bool {
func (w *FileWorkspace) alreadyClonedHEAD(log logging.SimpleLogging, cloneDir string, p models.PullRequest) bool {
// If the directory isn't there or isn't readable, we cannot already be cloned
if _, err := os.Stat(cloneDir); err != nil {
return false
Expand Down Expand Up @@ -147,7 +147,7 @@ func (w *FileWorkspace) alreadyClonedHEAD(log *logging.SimpleLogging, cloneDir s
// fetchBranch causes the repository to fetch the most recent version of the given branch
// in a shallow fashion. This ensures we can access files from this branch, enabling later
// reading of files from this revision.
func (w *FileWorkspace) fetchBranch(log *logging.SimpleLogging, cloneDir, branch string) (string, error) {
func (w *FileWorkspace) fetchBranch(log logging.SimpleLogging, cloneDir, branch string) (string, error) {
log.Debug("fetching branch %s into repository %s", branch, cloneDir)

fetchCmd := exec.Command("git", "fetch", "--depth=1", "origin", fmt.Sprintf("+refs/heads/%s:refs/remotes/origin/%s", branch, branch))
Expand Down

0 comments on commit 812d481

Please sign in to comment.