blob: 91ee783b29fa9c9a3c777662c217e2458739ec81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// +build static,system_libgit2
package commit
import (
"fmt"
"path/filepath"
git "github.com/libgit2/git2go/v31"
"gitlab.com/gitlab-org/gitaly/internal/git2go"
)
func applyCreateDirectory(action git2go.CreateDirectory, repo *git.Repository, index *git.Index) error {
if err := validateFileDoesNotExist(index, action.Path); err != nil {
return err
} else if err := validateDirectoryDoesNotExist(index, action.Path); err != nil {
return err
}
emptyBlobOID, err := repo.CreateBlobFromBuffer([]byte{})
if err != nil {
return fmt.Errorf("create blob from buffer: %w", err)
}
return index.Add(&git.IndexEntry{
Path: filepath.Join(action.Path, ".gitkeep"),
Mode: git.FilemodeBlob,
Id: emptyBlobOID,
})
}
|