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

Add optional username and email fields to repo for commits #5477

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

Warashi
Copy link
Contributor

@Warashi Warashi commented Jan 16, 2025

What this PR does:

This PR adds username and email fields to the repo struct.

Why we need it:

We need these fields to do the git commit.
Originally, these fields are set when creating the new repo in the git client's Clone method.
When I implemented the CopyToModify method, I forgot to set these fields.

ref;

pipecd/pkg/git/client.go

Lines 239 to 244 in f7e3bbc

if c.username != "" || c.email != "" {
if err := r.setUser(ctx, c.username, c.email); err != nil {
return nil, fmt.Errorf("failed to set user: %v", err)
}
}

Which issue(s) this PR fixes:

Without this PR, the piped cannot handle the GIT_UPDATE event successfully.

How to reproduce the issue

Remove global git config, run piped, and send the event with pipectl.

You will see the log like below.

{"severity":"ERROR","eventTime":1736988484.684635,"logger":"piped.piped.event-watcher","caller":"eventwatcher/eventwatcher.go:403","message":"failed to commit outdated files","serviceContext":{"service":"piped.piped","version":"unspecified"},"error":"failed to commit, branch: main, error: err: exit status 128, out: Author identity unknown\n\n*** Please tell me who you are.\n\nRun\n\n  git config --global user.email \"[email protected]\"\n  git config --global user.name \"Your Name\"\n\nto set your account's default identity.\nOmit --global to set the identity only in this repository.\n\nfatal: unable to auto-detect email address (got 'warashi@nixos.(none)')\n","stacktrace":"github.com/pipe-cd/pipecd/pkg/app/piped/eventwatcher.(*watcher).execute\n\t/home/warashi/ghq/github.com/pipe-cd/pipecd/pkg/app/piped/eventwatcher/eventwatcher.go:403\ngithub.com/pipe-cd/pipecd/pkg/app/piped/eventwatcher.(*watcher).run\n\t/home/warashi/ghq/github.com/pipe-cd/pipecd/pkg/app/piped/eventwatcher/eventwatcher.go:294"}

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

@Warashi Warashi enabled auto-merge (squash) January 16, 2025 00:58
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

LGTM

@Warashi Warashi merged commit 025936b into master Jan 16, 2025
16 checks passed
@Warashi Warashi deleted the git-worktree-author-fix branch January 16, 2025 01:04
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Project coverage is 26.24%. Comparing base (58fda21) to head (38b5c92).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/git/repo.go 42.85% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5477   +/-   ##
=======================================
  Coverage   26.24%   26.24%           
=======================================
  Files         458      458           
  Lines       49364    49370    +6     
=======================================
+ Hits        12954    12956    +2     
- Misses      35383    35386    +3     
- Partials     1027     1028    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

github-actions bot pushed a commit that referenced this pull request Jan 16, 2025
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: pipecd-bot <[email protected]>
@github-actions github-actions bot mentioned this pull request Jan 16, 2025
Warashi added a commit that referenced this pull request Jan 16, 2025
…5478)

Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
Signed-off-by: pipecd-bot <[email protected]>
Co-authored-by: Shinnosuke Sawada-Dazai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants