pipe-cd / pipecd

The One CD for All {applications, platforms, operations}
https://pipecd.dev
Apache License 2.0
1.09k stars 153 forks source link

Add test case for the commit with trailers #5322

Closed ffjlabo closed 5 days ago

ffjlabo commented 1 week ago

What this PR does:

as title

Why we need it:

Which issue(s) this PR fixes:

Part of #5320

Does this PR introduce a user-facing change?:

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 25.25%. Comparing base (b5089af) to head (fb9344b). Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #5322 +/- ## ========================================== - Coverage 25.28% 25.25% -0.03% ========================================== Files 444 444 Lines 47554 47554 ========================================== - Hits 12022 12012 -10 - Misses 34590 34599 +9 - Partials 942 943 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ffjlabo commented 1 week ago

📝 The trailer feature is supporterd from git 2.32.0. The test fails before the version.

#!/bin/sh

for i in $(seq 30 45); do
    GIT_VERSION=2.$i.0
    echo "test for git ${GIT_VERSION}  ============="
    asdf global git ${GIT_VERSION}
    go clean -testcache
    go test ./pkg/git/...
done
test for git 2.32.0  =============
?       github.com/pipe-cd/pipecd/pkg/git/gittest   [no test files]
ok      github.com/pipe-cd/pipecd/pkg/git   25.693s
test for git 2.31.0  =============
?       github.com/pipe-cd/pipecd/pkg/git/gittest   [no test files]
--- FAIL: TestAddCommit (2.02s)
    repo_test.go:109:
            Error Trace:    /Users/s14218/oss/pipe-cd/pipecd/pkg/git/repo_test.go:109
            Error:          Received unexpected error:
                            err: exit status 129, out: error: unknown option `trailer=Test-Hoge: fuga'
                            usage: git commit [<options>] [--] <pathspec>...

                                -q, --quiet           suppress summary after successful commit
                                -v, --verbose         show diff in commit message template

                            Commit message options
                                -F, --file <file>     read message from file
                                --author <author>     override author for commit
                                --date <date>         override date for commit
                                -m, --message <message>
                                                      commit message
                                -c, --reedit-message <commit>
                                                      reuse and edit message from specified commit
                                -C, --reuse-message <commit>
                                                      reuse message from specified commit
                                --fixup <commit>      use autosquash formatted message to fixup specified commit
                                --squash <commit>     use autosquash formatted message to squash specified commit
                                --reset-author        the commit is authored by me now (used with -C/-c/--amend)
                                -s, --signoff         add a Signed-off-by trailer
                                -t, --template <file>
                                                      use specified template file
                                -e, --edit            force edit of commit
                                --cleanup <mode>      how to strip spaces and #comments from message
                                --status              include status in commit message template
                                -S, --gpg-sign[=<key-id>]
                                                      GPG sign commit

                            Commit contents options
                                -a, --all             commit all changed files
                                -i, --include         add specified files to index for commit
                                --interactive         interactively add files
                                -p, --patch           interactively add changes
                                -o, --only            commit only specified files
                                -n, --no-verify       bypass pre-commit and commit-msg hooks
                                --dry-run             show what would be committed
                                --short               show status concisely
                                --branch              show branch information
                                --ahead-behind        compute full ahead/behind values
                                --porcelain           machine-readable output
                                --long                show status in long format (default)
                                -z, --null            terminate entries with NUL
                                --amend               amend previous commit
                                --no-post-rewrite     bypass post-rewrite hook
                                -u, --untracked-files[=<mode>]
                                                      show untracked files, optional modes: all, normal, no. (Default: all)
                                --pathspec-from-file <file>
                                                      read pathspec from file
                                --pathspec-file-nul   with --pathspec-from-file, pathspec elements are separated with NUL character

            Test:           TestAddCommit
--- FAIL: TestCommitChanges (3.31s)
    repo_test.go:163:
            Error Trace:    /Users/s14218/oss/pipe-cd/pipecd/pkg/git/repo_test.go:163
            Error:          Received unexpected error:
                            failed to commit, branch: new-branch2, error: err: exit status 129, out: error: unknown option `trailer=test: hoge'
                            usage: git commit [<options>] [--] <pathspec>...

                                -q, --quiet           suppress summary after successful commit
                                -v, --verbose         show diff in commit message template

                            Commit message options
                                -F, --file <file>     read message from file
                                --author <author>     override author for commit
                                --date <date>         override date for commit
                                -m, --message <message>
                                                      commit message
                                -c, --reedit-message <commit>
                                                      reuse and edit message from specified commit
                                -C, --reuse-message <commit>
                                                      reuse message from specified commit
                                --fixup <commit>      use autosquash formatted message to fixup specified commit
                                --squash <commit>     use autosquash formatted message to squash specified commit
                                --reset-author        the commit is authored by me now (used with -C/-c/--amend)
                                -s, --signoff         add a Signed-off-by trailer
                                -t, --template <file>
                                                      use specified template file
                                -e, --edit            force edit of commit
                                --cleanup <mode>      how to strip spaces and #comments from message
                                --status              include status in commit message template
                                -S, --gpg-sign[=<key-id>]
                                                      GPG sign commit

                            Commit contents options
                                -a, --all             commit all changed files
                                -i, --include         add specified files to index for commit
                                --interactive         interactively add files
                                -p, --patch           interactively add changes
                                -o, --only            commit only specified files
                                -n, --no-verify       bypass pre-commit and commit-msg hooks
                                --dry-run             show what would be committed
                                --short               show status concisely
                                --branch              show branch information
                                --ahead-behind        compute full ahead/behind values
                                --porcelain           machine-readable output
                                --long                show status in long format (default)
                                -z, --null            terminate entries with NUL
                                --amend               amend previous commit
                                --no-post-rewrite     bypass post-rewrite hook
                                -u, --untracked-files[=<mode>]
                                                      show untracked files, optional modes: all, normal, no. (Default: all)
                                --pathspec-from-file <file>
                                                      read pathspec from file
                                --pathspec-file-nul   with --pathspec-from-file, pathspec elements are separated with NUL character

            Test:           TestCommitChanges
FAIL
FAIL    github.com/pipe-cd/pipecd/pkg/git   24.501s
FAIL