Skip to content

Commit

Permalink
fix tags
Browse files Browse the repository at this point in the history
new tags seem to be delivered with 0000000000000000000000000000000000000000 as
req.Build.Before. It that happens we test just the last commit.
  • Loading branch information
foosinn committed Mar 15, 2019
1 parent 3c2d27c commit f7013fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package plugin
import (
"context"
"errors"
"fmt"
"path"
"regexp"
"strconv"
Expand Down Expand Up @@ -89,7 +90,12 @@ func (p *plugin) Find(ctx context.Context, req *config.Request) (*drone.Config,
}
} else {
// use diff to get changed files
changes, _, err := client.Repositories.CompareCommits(ctx, req.Repo.Namespace, req.Repo.Name, req.Build.Before, req.Build.After)
before := req.Build.Before
// fix before if its zeroed (i.e. new tag).
if before == "0000000000000000000000000000000000000000" {
before = fmt.Sprintf("%s~1", req.Build.After)
}
changes, _, err := client.Repositories.CompareCommits(ctx, req.Repo.Namespace, req.Repo.Name, before, req.Build.After)
if err != nil {
logrus.Errorf("Unable to fetch diff: '%v', server: '%s'", err, p.server)
return nil, err
Expand Down

0 comments on commit f7013fa

Please sign in to comment.