cake-contrib / Cake_Git

Cake AddIn that extends Cake with Git features using LibGit2 and LibGit2Sharp
https://cakebuild.net/extensions/cake-git
Other
39 stars 64 forks source link

GitFindRootFromPath will loop forever if a valid Git repository can't be found. #127

Closed kcamp closed 1 year ago

kcamp commented 4 years ago

If you call GitFindRootFromPath("./") from a path where no ancestor contains a valid Git repository, the method will loop forever.

Repro Create a folder where a valid git repository is not accessible - i.e., c:\git\repro and add this cake script.

#addin "nuget:?package=Cake.Git&version=0.22"

Task("Default")
  .Does(() => {
    Information("Finding git root");
    GitFindRootFromPath(MakeAbsolute(new DirectoryPath(".")));
  });

RunTarget("Default");

The task will get caught in the do..while loop and loop forever.

https://github.com/cake-contrib/Cake_Git/blob/63ee1c9219527e86cb7488922c85645542ac1b76/src/Cake.Git/GitAliases.Repository.cs#L192-L201

We need to add a termination condition to the loop and allow the exception to be thrown.

nils-a commented 1 year ago

Closed in #128