aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit/dotgit_setref.go
diff options
context:
space:
mode:
authorAntonio Jesus Navarro Perez <antnavper@gmail.com>2018-06-05 18:33:27 +0200
committerAntonio Jesus Navarro Perez <antnavper@gmail.com>2018-06-05 18:34:08 +0200
commitb0d807a1ae0687ef3a01d78c1dc5e55f7217268f (patch)
tree3a9d6f21cad1af18d940abcc17ddb1337e78146d /storage/filesystem/internal/dotgit/dotgit_setref.go
parent8955f060a3cba36a56ac334576eba4123f6e918a (diff)
downloadgo-git-b0d807a1ae0687ef3a01d78c1dc5e55f7217268f.tar.gz
dotgit: Move package outside internal.
Signed-off-by: Antonio Jesus Navarro Perez <antnavper@gmail.com>
Diffstat (limited to 'storage/filesystem/internal/dotgit/dotgit_setref.go')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit_setref.go43
1 files changed, 0 insertions, 43 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit_setref.go b/storage/filesystem/internal/dotgit/dotgit_setref.go
deleted file mode 100644
index d27c1a3..0000000
--- a/storage/filesystem/internal/dotgit/dotgit_setref.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// +build !norwfs
-
-package dotgit
-
-import (
- "os"
-
- "gopkg.in/src-d/go-git.v4/plumbing"
- "gopkg.in/src-d/go-git.v4/utils/ioutil"
-)
-
-func (d *DotGit) setRef(fileName, content string, old *plumbing.Reference) (err error) {
- // If we are not checking an old ref, just truncate the file.
- mode := os.O_RDWR | os.O_CREATE
- if old == nil {
- mode |= os.O_TRUNC
- }
-
- f, err := d.fs.OpenFile(fileName, mode, 0666)
- if err != nil {
- return err
- }
-
- defer ioutil.CheckClose(f, &err)
-
- // Lock is unlocked by the deferred Close above. This is because Unlock
- // does not imply a fsync and thus there would be a race between
- // Unlock+Close and other concurrent writers. Adding Sync to go-billy
- // could work, but this is better (and avoids superfluous syncs).
- err = f.Lock()
- if err != nil {
- return err
- }
-
- // this is a no-op to call even when old is nil.
- err = d.checkReferenceAndTruncate(f, old)
- if err != nil {
- return err
- }
-
- _, err = f.Write([]byte(content))
- return err
-}