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

feat: default to a dedicated bot user when committing changes #201

Merged
merged 1 commit into from
May 18, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/content/config/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ commitMessage: "chore: a custom commit message"
# .uplift.yml

# Changes the commit author used by uplift when committing any staged changes.
# Useful if you want uplift to be treated as a bot and own its commits.
#
# Defaults to the author who last committed to the repository and effectively
# triggered uplift. Uplift likes to give credit to the author that is releasing
# a new feature or fixing that bug they found.
# Defaults to the Uplift Bot: uplift-bot <uplift@gembaadvantage.com>
commitAuthor:
# Name of the author
#
Expand Down
4 changes: 2 additions & 2 deletions internal/task/nextcommit/nextcommit.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (t Task) Skip(ctx *context.Context) bool {
// from the last commit or by generating a user defined commit
func (t Task) Run(ctx *context.Context) error {
c := git.CommitDetails{
Author: ctx.CommitDetails.Author,
Email: ctx.CommitDetails.Email,
Author: "uplift-bot",
Email: "uplift@gembaadvantage.com",
Message: fmt.Sprintf("ci(uplift): uplifted for version %s", ctx.NextVersion.Raw),
}

Expand Down
21 changes: 3 additions & 18 deletions internal/task/nextcommit/nextcommit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

"github.com/gembaadvantage/uplift/internal/config"
"github.com/gembaadvantage/uplift/internal/context"
"github.com/gembaadvantage/uplift/internal/git"
"github.com/gembaadvantage/uplift/internal/semver"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -43,7 +42,7 @@ func TestSkip(t *testing.T) {
}))
}

func TestRun_DefaultCommitMessage(t *testing.T) {
func TestRun(t *testing.T) {
ctx := &context.Context{
NextVersion: semver.Version{
Raw: "0.1.0",
Expand All @@ -52,25 +51,11 @@ func TestRun_DefaultCommitMessage(t *testing.T) {

err := Task{}.Run(ctx)
require.NoError(t, err)
assert.Equal(t, "uplift-bot", ctx.CommitDetails.Author)
assert.Equal(t, "uplift@gembaadvantage.com", ctx.CommitDetails.Email)
assert.Equal(t, "ci(uplift): uplifted for version 0.1.0", ctx.CommitDetails.Message)
}

func TestRun_ImpersonatesAuthor(t *testing.T) {
cd := git.CommitDetails{
Author: "joe.bloggs",
Email: "joe.bloggs@example.com",
}

ctx := &context.Context{
CommitDetails: cd,
}

err := Task{}.Run(ctx)
require.NoError(t, err)
assert.Equal(t, cd.Author, ctx.CommitDetails.Author)
assert.Equal(t, cd.Email, ctx.CommitDetails.Email)
}

func TestRun_CustomCommitDetails(t *testing.T) {
ctx := &context.Context{
Config: config.Uplift{
Expand Down