Skip to content

Commit aa09c09

Browse files
author
shayanhabibi
committed
fix: index write after staging
1 parent ef834de commit aa09c09

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

Partas.GitNet/BuildHelpers.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ module CrackedProject =
7070
let index = runtime.repo |> Repository.index
7171
for file in files do
7272
index |> Index.addFile file
73+
index |> Index.write
7374
Ok ()
7475
with e ->
7576
Error e

Partas.GitNet/GitNetRuntime.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type GitNetRuntime(config: GitNetConfig) =
7272
let index = this.repo |> Repository.index
7373
try
7474
for file in files do index |> Index.addFile file
75+
index |> Index.write
7576
with e -> printfn $"Failed to stage files:\n %A{e}"
7677
/// <summary>
7778
/// Commits staged files.
@@ -81,14 +82,17 @@ type GitNetRuntime(config: GitNetConfig) =
8182
/// <param name="message">Message for commit</param>
8283
/// <param name="date">Date</param>
8384
/// <param name="appendCommit">Whether to append to last commit</param>
84-
member this.CommitChanges(?username,?email,?message: string, ?date: DateTimeOffset, ?appendCommit: bool) =
85+
/// <param name="writeIndex">Whether to write the index before committing. Default <c>true</c></param>
86+
member this.CommitChanges(?username,?email,?message: string, ?date: DateTimeOffset, ?appendCommit: bool, ?writeIndex) =
8587
let appendCommit = appendCommit |> Option.defaultValue commitHasBeenMade
8688
let username = defaultArg username "GitHub Action"
8789
let email = defaultArg email "41898282+github-actions[bot]@users.noreply.github.com"
8890
let date = defaultArg date DateTimeOffset.Now
8991
let message = defaultArg message "[skip ci]\n\nGitNet auto file update."
92+
let writeIndex = defaultArg writeIndex true
9093
let signature = Signature(name = username, email = email, ``when`` = date)
9194
try
95+
if writeIndex then this.repo.Index.Write()
9296
this
9397
.repo
9498
.Commit(message, signature, signature, CommitOptions(AllowEmptyCommit = false, AmendPreviousCommit = appendCommit))

Partas.GitNet/Program.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ type GitNetRuntime with
3131
try
3232
this.repo
3333
|> Repository.index
34-
|> Index.addFile (System.IO.Path.GetRelativePath(this.rootDir, path))
34+
|> fun idx ->
35+
Index.addFile (System.IO.Path.GetRelativePath(this.rootDir, path)) idx
36+
Index.write idx
3537
with e ->
3638
e
3739
|> printfn "%A"

Partas.GitNet/RepoCracker.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ type GitNetRuntime with
375375
|> AssemblyInfoFile.createFSharp assemblyPath
376376
if stageFiles then
377377
this.repo.Index.Add (Path.GetRelativePath(this.rootDir, assemblyPath))
378+
this.repo.Index.Write()
378379
this.StatAssemblyFile assemblyPath
379380
Ok()
380381
with e ->

0 commit comments

Comments
 (0)