github.com/1800alex/go-git-cmd-wrapper@v1.1.0/init/init_custom.go (about)

     1  package init
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/ldez/go-git-cmd-wrapper/types"
     7  )
     8  
     9  // SharedWithPerms Shared Specify that the Git repository is to be shared amongst several users.
    10  // This allows users belonging to the same group to push into that repository.
    11  // When specified, the config variable 'core.sharedRepository' is set so that files and directories under $GIT_DIR are created with the requested permissions.
    12  // When not specified, Git will use permissions reported by umask(2).
    13  // --shared[=(false|true|umask|group|all|world|everybody|0xxx)]
    14  func SharedWithPerms(permissions string) func(*types.Cmd) {
    15  	return func(g *types.Cmd) {
    16  		if len(permissions) == 0 {
    17  			g.AddOptions("--shared")
    18  		} else {
    19  			g.AddOptions(fmt.Sprintf("--shared=%s", permissions))
    20  		}
    21  	}
    22  }
    23  
    24  // Directory path.
    25  func Directory(directory string) func(*types.Cmd) {
    26  	return func(g *types.Cmd) {
    27  		g.AddOptions(directory)
    28  	}
    29  }