Skip to content

Commit ecc34af

Browse files
committed
CI: fix tdsharp updater
There were two issues with the existing code: 1. isDescendant function was incorrectly called: the potentialAscendant and potentialDescendant arguments were mixed up. The first argument is supposed to be older (it's what the function checks). 2. The fetchGitSubmodule function wasn't only fetching it, but also updating it to the latest commit. As the result, it all lead to a paradoxical situation when the Git submodule only gets updated if the last tagged commit in tdsharp is an ancestor of the last commit in tdsharp — meaning the updates happened on any new commits after a tdsharp release.
1 parent 5c7e238 commit ecc34af

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

update-tdsharp.fsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ let processCommandResult(result: CommandResult, assertSuccess: bool) =
3737

3838
let assertCommandResult result = processCommandResult(result, true)
3939

40-
let isDescendant potentialDescendant potentialAscendant =
41-
if potentialDescendant = potentialAscendant then false
40+
let isAncestor (potentialAncestor: string) (potentialDescendant: string) =
41+
if potentialAncestor = potentialDescendant then false
4242
else
4343

4444
let commandResult =
4545
Command.Run(
4646
"git",
4747
arguments = [|
4848
"merge-base";
49-
"--is-ancestor"; potentialAscendant; potentialDescendant
49+
"--is-ancestor"; potentialAncestor; potentialDescendant
5050
|],
5151
options = fun opts -> opts.WorkingDirectory tdSharpSources.Value |> ignore
5252
).Result
@@ -76,17 +76,18 @@ let readLatestVersion() = task {
7676
}
7777

7878
let fetchGitSubmodule() =
79-
printfn "Fetching the Git sources"
79+
printfn "Initializing the Git submodule"
8080
Command.Run(
8181
"git",
82-
"submodule", "update", "--init", "--remote", "--", tdSharpSources.Value
82+
"submodule", "update", "--init", "--", tdSharpSources.Value
8383
).Result |> assertCommandResult
84+
printfn "Fetching the Git submodule…"
8485
Command.Run(
8586
"git",
8687
arguments = [| "fetch"; "--all" |],
8788
options = fun opts -> opts.WorkingDirectory tdSharpSources.Value |> ignore
8889
).Result |> assertCommandResult
89-
printfn "Git sources fetched."
90+
printfn "Git submodule fetched."
9091

9192
let updateGitSubmodule(commitHash: string) =
9293
printfn $"Checking out the Git submodule at commit {commitHash}…"
@@ -118,7 +119,7 @@ let latestCommit = latestTag.Commit.Sha
118119

119120
let result =
120121
printfn $"Current commit: {currentCommit}, latest commit: {latestCommit}."
121-
if isDescendant currentCommit latestCommit then
122+
if isAncestor currentCommit latestCommit then
122123
printfn $"Updating to {latestTag.Name} ({latestCommit})…"
123124
Some <| updateTo latestTag
124125
else

0 commit comments

Comments
 (0)