Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion services/repository/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ
}()

// 2 - check whether the repository with the same storage exists
isExist, err := gitrepo.IsRepositoryExist(ctx, generateRepo)
var isExist bool
isExist, err = gitrepo.IsRepositoryExist(ctx, generateRepo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think it is a bug

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 103 will check if err is nil. Since the directory exist, we need to cleanupReposioty, so that this err should be the returned parameter but not a local variable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show me why


func TestError(t *testing.T) {
	f := func(t *testing.T) (err error) {
		defer func() {
			assert.ErrorContains(t, err, "error")
		}()
		val, err := 1, nil
		_ = val
		_ = err
		assert.NoError(t, err)
		return errors.New("error")
	}
	assert.ErrorContains(t, f(t), "error")
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I see. The return will assign the error to the returned parameter err.

if err != nil {
log.Error("Unable to check if %s exists. Error: %v", generateRepo.FullName(), err)
return nil, err
Expand Down