Skip to content

[Ask] is this support Allow Empty Commit with Message? #189

Closed

Description

@kholisrag

[Ask] is this library support Allow Empty Commit with Message?

like this when we use git :

 git commit --allow-empty -m "Trigger notification"

Thanks 🙏🏻

Activity

  1. kamontat commented on Apr 18, 2021

    @kamontat

    Any update @go-git

  2. weakish commented on Oct 1, 2021

    @weakish

    --allow-empty is an option to prevent accidentally recording an empty commit when using the git command line.
    go-git is not for interactive use and it does not check this.
    In other words, you can considered that --allow-empty is used in every (*git.Worktree).Commit(...).

    You can create a test repository to verify this.
    Something like:

    mkdir test
    cd test
    git init
    package main
    
    import (
    	"time"
      	"github.com/go-git/go-git/v5"
    	"github.com/go-git/go-git/v5/plumbing/object"
    )
    
    func main() {
                            
    			r, _ := git.PlainOpen("test")
    			w, _ := r.Worktree()
    			w.Commit(body, &git.CommitOptions{
    				Author: &object.Signature{
    					Name:  "your name",
    					Email: "your email",
    					When:  time.Now(),
    				},
    			})
    }

    The code sample above is untested, so it may contain errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions