Skip to content

Commit

Permalink
fix(build): Save only first line of Commit message
Browse files Browse the repository at this point in the history
* Fix db Error 1406: Data too long for column 'commit_message' at row 1
* Get docker socket from client Environ
  • Loading branch information
Porsh33 committed Apr 14, 2022
1 parent 93485da commit af4b6f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions server/store/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ func (s buildStore) GenerateBuild(repo *core.Repository, base *core.GitHook) ([]
base.After = commit.Sha
}
if base.Message == "" {
base.Message = commit.Message
// Fix Database Error 1406: Data too long for column 'commit_message' at row 1
base.Message = strings.Split(commit.Message, "\n")[0]
}
}
content, err := scm.FindContent(repo.FullName, base.After, ".abstruse.yml")
Expand Down Expand Up @@ -257,7 +258,7 @@ func (s buildStore) TriggerBuild(opts core.TriggerBuildOpts) ([]*core.Job, error
sha = commit.Sha

build.Commit = commit.Sha
build.CommitMessage = commit.Message
build.CommitMessage = strings.Split(commit.Message, "\n")[0]
build.AuthorLogin = commit.Author.Login
build.AuthorName = commit.Author.Name
build.AuthorEmail = commit.Author.Email
Expand All @@ -274,7 +275,7 @@ func (s buildStore) TriggerBuild(opts core.TriggerBuildOpts) ([]*core.Job, error
}

build.Commit = commit.Sha
build.CommitMessage = commit.Message
build.CommitMessage = strings.Split(commit.Message, "\n")[0]
build.AuthorLogin = commit.Author.Login
build.AuthorName = commit.Author.Name
build.AuthorEmail = commit.Author.Email
Expand Down
6 changes: 3 additions & 3 deletions worker/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
// RunContainer runs container.
func RunContainer(name, image string, job *api.Job, config *config.Config, env []string, dir string, logch chan<- []byte) error {
ctx := context.Background()
cli, err := client.NewClientWithOpts()
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
return err
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func RunContainer(name, image string, job *api.Job, config *config.Config, env [

// StopContainer stops the container.
func StopContainer(name string) error {
cli, err := client.NewClientWithOpts()
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
return err
}
Expand Down Expand Up @@ -224,7 +224,7 @@ func exec(cli *client.Client, id string, cmd, env []string) (types.HijackedRespo

// ContainerExists finds container by name and if exists returns id.
func ContainerExists(name string) (string, bool) {
cli, _ := client.NewClientWithOpts()
cli, _ := client.NewClientWithOpts(client.FromEnv)

containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{All: true})
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions worker/docker/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ImageBuildOutput struct {
// BuildImage builds the docker image.
func BuildImage(tags []string, dockerFile string) (types.ImageBuildResponse, error) {
ctx := context.Background()
cli, err := client.NewClientWithOpts()
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func BuildImage(tags []string, dockerFile string) (types.ImageBuildResponse, err
// PushImage pushes image to the registry.
func PushImage(tag string) (io.ReadCloser, error) {
ctx := context.Background()
cli, err := client.NewClientWithOpts()
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
panic(err)
}
Expand All @@ -86,7 +86,7 @@ func PushImage(tag string) (io.ReadCloser, error) {
// PullImage pulls image from the registry.
func PullImage(image string, config *config.Registry) error {
ctx := context.Background()
cli, err := client.NewClientWithOpts()
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
panic(err)
}
Expand All @@ -113,7 +113,7 @@ func PullImage(image string, config *config.Registry) error {

// ListImages returns all images.
func ListImages() []types.ImageSummary {
cli, err := client.NewClientWithOpts()
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit af4b6f8

Please sign in to comment.