Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean: removed deprecated git.short_hash option #931

Merged
merged 2 commits into from Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 4 additions & 12 deletions internal/pipe/git/git.go
Expand Up @@ -5,7 +5,6 @@ import (
"strings"

"github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/git"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/pkg/context"
Expand All @@ -24,9 +23,6 @@ func (Pipe) Run(ctx *context.Context) error {
if _, err := exec.LookPath("git"); err != nil {
return ErrNoGit
}
if ctx.Config.Git.ShortHash {
deprecate.Notice("git.short_hash")
}
info, err := getInfo(ctx)
if err != nil {
return err
Expand All @@ -53,7 +49,7 @@ func getInfo(ctx *context.Context) (context.GitInfo, error) {
if !git.IsRepo() {
return context.GitInfo{}, ErrNotRepository
}
info, err := getGitInfo(ctx)
info, err := getGitInfo()
if err != nil && ctx.Snapshot {
log.WithError(err).Warn("ignoring errors because this is a snapshot")
if info.Commit == "" {
Expand All @@ -64,7 +60,7 @@ func getInfo(ctx *context.Context) (context.GitInfo, error) {
return info, err
}

func getGitInfo(ctx *context.Context) (context.GitInfo, error) {
func getGitInfo() (context.GitInfo, error) {
short, err := getShortCommit()
if err != nil {
return context.GitInfo{}, errors.Wrap(err, "couldn't get current commit")
Expand All @@ -73,18 +69,14 @@ func getGitInfo(ctx *context.Context) (context.GitInfo, error) {
if err != nil {
return context.GitInfo{}, errors.Wrap(err, "couldn't get current commit")
}
var commit = full
if ctx.Config.Git.ShortHash {
commit = short
}
url, err := getURL()
if err != nil {
return context.GitInfo{}, errors.Wrap(err, "couldn't get remote URL")
}
tag, err := getTag()
if err != nil {
return context.GitInfo{
Commit: commit,
Commit: full,
FullCommit: full,
ShortCommit: short,
URL: url,
Expand All @@ -93,7 +85,7 @@ func getGitInfo(ctx *context.Context) (context.GitInfo, error) {
}
return context.GitInfo{
CurrentTag: tag,
Commit: commit,
Commit: full,
FullCommit: full,
ShortCommit: short,
URL: url,
Expand Down
14 changes: 0 additions & 14 deletions internal/pipe/snapshot/snapshot_test.go
Expand Up @@ -34,20 +34,6 @@ func TestDefaultSet(t *testing.T) {
assert.Equal(t, "snap", ctx.Config.Snapshot.NameTemplate)
}

func TestSnapshotNameShortCommitHash(t *testing.T) {
var ctx = context.New(config.Project{
Snapshot: config.Snapshot{
NameTemplate: "{{.ShortCommit}}",
},
})
ctx.Snapshot = true
ctx.Config.Git.ShortHash = true
ctx.Git.CurrentTag = "v1.2.3"
ctx.Git.ShortCommit = "123"
assert.NoError(t, Pipe{}.Run(ctx))
assert.Equal(t, ctx.Version, "123")
}

func TestSnapshotInvalidNametemplate(t *testing.T) {
var ctx = context.New(config.Project{
Snapshot: config.Snapshot{
Expand Down
6 changes: 0 additions & 6 deletions pkg/config/config.go
Expand Up @@ -273,11 +273,6 @@ type EnvFiles struct {
GitHubToken string `yaml:"github_token,omitempty"`
}

// Git config
type Git struct {
ShortHash bool `yaml:"short_hash,omitempty"`
}

// Before config
type Before struct {
Hooks []string `yaml:",omitempty"`
Expand Down Expand Up @@ -325,7 +320,6 @@ type Project struct {
Dist string `yaml:",omitempty"`
Sign Sign `yaml:",omitempty"`
EnvFiles EnvFiles `yaml:"env_files,omitempty"`
Git Git `yaml:",omitempty"`
Before Before `yaml:",omitempty"`

// this is a hack ¯\_(ツ)_/¯
Expand Down
2 changes: 2 additions & 0 deletions www/content/deprecations.md
Expand Up @@ -108,6 +108,8 @@ dockers:
## git.short_hash

> since 2018-10-03
>
> removed 2019-01-19

This property was being used to tell GoReleaser to use short git hashes
instead of the full ones. This has been removed in favor of specific
Expand Down