mirror of
https://github.com/go-gitea/git.git
synced 2026-02-05 15:45:40 +01:00
initial command
This commit is contained in:
21
repo.go
Normal file
21
repo.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package git
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// InitRepository initializes a new Git repository in choice of bare or not.
|
||||
func InitRepository(repoPath string, bare bool) error {
|
||||
os.MkdirAll(repoPath, os.ModePerm)
|
||||
|
||||
cmd := NewCommand("init")
|
||||
if bare {
|
||||
cmd.AddArguments("--bare")
|
||||
}
|
||||
_, err := cmd.RunInDir(repoPath)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user