diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-05 08:51:17 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-05 08:51:17 +0800 |
commit | 7c341685f878aa8fd4c49788cf8cc0d8c5c6e127 (patch) | |
tree | 5295f1f4020e85c065e98fcb88ec217ad66e078a /git_format_patch.go | |
parent | config: Add explanatory comments (diff) | |
download | forge-7c341685f878aa8fd4c49788cf8cc0d8c5c6e127.tar.gz forge-7c341685f878aa8fd4c49788cf8cc0d8c5c6e127.tar.zst forge-7c341685f878aa8fd4c49788cf8cc0d8c5c6e127.zip |
*: Replace some := with var
Diffstat (limited to '')
-rw-r--r-- | git_format_patch.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/git_format_patch.go b/git_format_patch.go index ecec6d9..2cf66ed 100644 --- a/git_format_patch.go +++ b/git_format_patch.go @@ -14,18 +14,21 @@ import ( // get_patch_from_commit formats a commit object as if it was returned by // git-format-patch. -func format_patch_from_commit(commit *object.Commit) (string, error) { - _, patch, err := get_patch_from_commit(commit) - if err != nil { +func format_patch_from_commit(commit *object.Commit) (final string, err error) { + var patch *object.Patch + var buf bytes.Buffer + var author object.Signature + var date string + var commit_msg_title, commit_msg_details string + + if _, patch, err = get_patch_from_commit(commit); err != nil { return "", err } - var buf bytes.Buffer - - author := commit.Author - date := author.When.Format(time.RFC1123Z) + author = commit.Author + date = author.When.Format(time.RFC1123Z) - commit_msg_title, commit_msg_details, _ := strings.Cut(commit.Message, "\n") + commit_msg_title, commit_msg_details, _ = strings.Cut(commit.Message, "\n") // This date is hardcoded in Git. fmt.Fprintf(&buf, "From %s Mon Sep 17 00:00:00 2001\n", commit.Hash) |