Ref disambiguation, and barebones Log (doesn't correspond to any of git's logs in order)

This commit is contained in:
Smaug123
2020-05-03 17:28:20 +01:00
parent f550ca4f84
commit 9a902bd11c
11 changed files with 380 additions and 2 deletions

29
Git/Reference.fs Normal file
View File

@@ -0,0 +1,29 @@
namespace Git
type ReferenceUpdate =
{
Was : Hash option
Now : Hash
}
[<RequireQualifiedAccess>]
module Reference =
let write (r : Repository) (hash : Hash) (name : string) : ReferenceUpdate =
let refFile = r.Fs.Path.Combine ((Repository.refDir r).FullName, "heads", name) |> r.Fs.FileInfo.FromFileName
let was =
if refFile.Exists then
r.Fs.File.ReadAllText refFile.FullName
|> Hash.ofString
|> Some
else
do
use _v = refFile.Create ()
()
None
r.Fs.File.WriteAllText (refFile.FullName, hash.ToString ())
{
Was = was
Now = hash
}