Git Product home page Git Product logo

cake_git's Introduction

Cake Git

NuGet

Cake AddIn that extends Cake with Git features using LibGit2 and LibGit2Sharp.

Build server Platform Status
AppVeyor Windows Build status
GitHub Actions Windows / Linux / macOS Build status

Documentation

Documentation is available at cakebuild.net/dsl/git.

Example usage

#addin nuget:?package=Cake.Git

var lastCommit = GitLogTip("PATH TO REPOSITORY");

Information(@"Last commit {0}
    Short message: {1}
    Author:        {2}
    Authored:      {3:yyyy-MM-dd HH:mm:ss}
    Committer:     {4}
    Committed:     {5:yyyy-MM-dd HH:mm:ss}",
    lastCommit.Sha,
    lastCommit.MessageShort,
    lastCommit.Author.Name,
    lastCommit.Author.When,
    lastCommit.Committer.Name,
    lastCommit.Committer.When
    );

Example output

Last commit fb5b9805e543d8d1715886f78c273dc45b51a928
    Short message: Added Travis test folding
    Author:        Mattias Karlsson
    Authored:      2016-08-16 085836
    Committer:     Mattias Karlsson
    Committed:     2016-08-16 085836

Discussion

For questions and to discuss ideas & feature requests, use the GitHub discussions on the Cake GitHub repository, under the Extension Q&A category.

Join in the discussion on the Cake repository

cake_git's People

Contributors

alea81 avatar arledesma avatar augustoproiete avatar bounz avatar daghb avatar dantttt avatar devlead avatar gep13 avatar gitfool avatar halex2005 avatar hanaure avatar ianmercer avatar jokay avatar katostoelen avatar kcamp avatar markobee avatar nikhilagrawaldotnet avatar nils-a avatar pascalberger avatar patriksvensson avatar philippbeckmann avatar phillipsj avatar roadrunner67 avatar sgaulding avatar skovsende avatar soroshsabz avatar waynehearn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cake_git's Issues

Dll not found while trying to get git version of a repo

Moved from cake-build/cake#1906
Originally asked by @johnnyasantoss

What You Are Seeing?

I'm having problems to get the git version of a repo using Cake.Git.
I think that the problem has something to do with the relative path for the .so file.

What is Expected?

Get the latest tag of the repo.

What version of Cake are you using?

  • 0.22.1

Are you running on a 32 or 64 bit system?

  • 64

What environment are you running on? Windows? Linux? Mac?

I'm using a docker image to build my project (or trying to).
Image: johnnyasantoss/dotnet-mono-docker:dotnet2.0-mono5.2-sdk

How Did You Get This To Happen? (Steps to Reproduce)

I tried to run a task and after compiling I got this error message.

Output Log

Gist: https://gist.github.com/anonymous/592a7073ba70b570b1090c92a39545df

Commit Count

Hello, in our build process we identify builds with the commit count using the output from command git rev-list --all --count.
Is it possible to get the repo commit count using this Addin?

Push with --tags

I am creating local tags and need to push them to remote. From the command line, I execute:

git push --tags

How would I do this with this library?

GitHasStagedChanges only considers modified files, not new/deleted/renamed

Looking at the source code for LibGit2Sharp's RepositoryStatus, it seems that the "Staged" list only contains existing files that were modified, not files that were added, deleted or renamed. These are stored in separate lists.
https://github.com/libgit2/libgit2sharp/blob/f8e2d42ed9051fa5a5348c1a13d006f0cc069bc7/LibGit2Sharp/RepositoryStatus.cs#L42

return new Dictionary<FileStatus, Action<RepositoryStatus, StatusEntry>>
            {
                { FileStatus.NewInWorkdir, (rs, s) => rs.untracked.Add(s) },
                { FileStatus.ModifiedInWorkdir, (rs, s) => rs.modified.Add(s) },
                { FileStatus.DeletedFromWorkdir, (rs, s) => rs.missing.Add(s) },
                { FileStatus.NewInIndex, (rs, s) => rs.added.Add(s) },
                { FileStatus.ModifiedInIndex, (rs, s) => rs.staged.Add(s) },
                { FileStatus.DeletedFromIndex, (rs, s) => rs.removed.Add(s) },
                { FileStatus.RenamedInIndex, (rs, s) => rs.renamedInIndex.Add(s) },
                { FileStatus.Ignored, (rs, s) => rs.ignored.Add(s) },
                { FileStatus.RenamedInWorkdir, (rs, s) => rs.renamedInWorkDir.Add(s) },
            };
        }

The Cake.Git method GitAliases.Repository.GitHasStagedChanges only checks the RepositoryStatus.Staged list, not the NewInIndex, DeletedFromIndex, RenamedInIndex.

public static bool GitHasStagedChanges(this ICakeContext context, DirectoryPath path)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
if (!context.FileSystem.Exist(path))
{
throw new RepositoryNotFoundException($"Path '{path}' doesn't exists.");
}
return context.UseRepository(
path,
repository => repository.RetrieveStatus().Staged.Any());
}

So if your changes only contain new files/deleted files/renamed files, GitHasStagedChanges will return false.

I'm not an expert on Git terminology, but I believe "staged" means any changes staged for commit, not just modified files?

If so, I guess it's a matter of discussion where the error lies, LibGit2Sharp's naming of the Staged-list is maybe a bit unfortunate, but I also guess that Cake.Git is consuming the RepositoryStatus "API" wrongly?

Centos 7.3 - GitClone throws 'The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.' - [SOLVED with steps]

What You Are Seeing?

Error when executing task to clone git repository.

System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so

What is Expected?

Clone repository

What version of Cake are you using?

  • 0.26.1.0

Are you running on a 32 or 64-bit system?

  • 64

What environment are you running on? Windows? Linux? Mac?

  • Linux: Centos 7.3

How Did You Get This To Happen? (Steps to Reproduce)

I've started script which contains following code (part of it):

    foreach (var repo in repositories)
    {
        var absolutePathToFolder = MakeAbsolute(Directory($"./../{repo}"));
        var fullRepoPath = $"<PATH TO THE REPO>";
        if (!DirectoryExists($"./../{repo}"))
        {
            Information($"Cloning {repo} ...");
            EnsureDirectoryExists(absolutePathToFolder);
            **GitClone(fullRepoPath, absolutePathToFolder, gitUserName, gitPassword);**
        }
    }

Output Log

An error occurred when executing task 'CloneRepositories'.
Error: One or more errors occurred.
The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in :0
at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in :0
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.Proxy.git_clone (System.String url, System.String workdir, LibGit2Sharp.Core.GitCloneOptions& opts) [0x00009] in :0
at LibGit2Sharp.Repository.Clone (System.String sourceUrl, System.String workdirPath, LibGit2Sharp.CloneOptions options) [0x000d3] in :0
at Cake.Git.GitAliases.GitClone (Cake.Core.ICakeContext context, System.String sourceUrl, Cake.Core.IO.DirectoryPath workDirectoryPath, System.String username, System.String password) [0x000bf] in <68d0f59d618141b69437a5843a3bbe02>:0
at Submission#0.GitClone (System.String sourceUrl, Cake.Core.IO.DirectoryPath workDirectoryPath, System.String username, System.String password) [0x0000c] in <6462928a9add4807b4daca2876b4797f>:0
at Submission#0.<>b__0_0 () [0x0007f] in <6462928a9add4807b4daca2876b4797f>:0
at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass6_0.b__0 (Cake.Core.ICakeContext context) [0x00000] in :0
at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass8_0.b__0 (Cake.Core.ICakeContext x) [0x00000] in :0
at Cake.Core.ActionTask+d__14.MoveNext () [0x00066] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in :0
at Cake.Core.DefaultExecutionStrategy+d__4.MoveNext () [0x000ee] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in :0
at Cake.Core.CakeEngine+d__29.MoveNext () [0x0013c] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in :0
at Cake.Core.CakeEngine+d__18.MoveNext () [0x00229] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at Cake.Scripting.BuildScriptHost+<RunTargetAsync>d__3.MoveNext () [0x0008d] in <1fcc25d1681b4774adb1422aeed887e6>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in :0
at Cake.Core.Scripting.ScriptHost.RunTarget (System.String target) [0x0000d] in :0
at Submission#0+<>d__0.MoveNext () [0x0018d] in <6462928a9add4807b4daca2876b4797f>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState+<RunSubmissionsAsync>d__91[TResult].MoveNext () [0x00186] in <7d37a385ddd24eeb96bd540d739cc157>:0
--- End of stack trace from previous location where exception was thrown ---
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject.Finalize () [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in :0
at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in :0
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.Proxy.git_clone (System.String url, System.String workdir, LibGit2Sharp.Core.GitCloneOptions& opts) [0x00009] in :0
at LibGit2Sharp.Repository.Clone (System.String sourceUrl, System.String workdirPath, LibGit2Sharp.CloneOptions options) [0x000d3] in :0
at Cake.Git.GitAliases.GitClone (Cake.Core.ICakeContext context, System.String sourceUrl, Cake.Core.IO.DirectoryPath workDirectoryPath, System.String username, System.String password) [0x000bf] in <68d0f59d618141b69437a5843a3bbe02>:0
at Submission#0.GitClone (System.String sourceUrl, Cake.Core.IO.DirectoryPath workDirectoryPath, System.String username, System.String password) [0x0000c] in <6462928a9add4807b4daca2876b4797f>:0
at Submission#0.<>b__0_0 () [0x0007f] in <6462928a9add4807b4daca2876b4797f>:0
at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass6_0.b__0 (Cake.Core.ICakeContext context) [0x00000] in :0
at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass8_0.b__0 (Cake.Core.ICakeContext x) [0x00000] in :0
at Cake.Core.ActionTask+d__14.MoveNext () [0x00066] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in :0
at Cake.Core.DefaultExecutionStrategy+d__4.MoveNext () [0x000ee] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in :0
at Cake.Core.CakeEngine+d__29.MoveNext () [0x0013c] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in :0
at Cake.Core.CakeEngine+d__18.MoveNext () [0x00229] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at Cake.Scripting.BuildScriptHost+<RunTargetAsync>d__3.MoveNext () [0x0008d] in <1fcc25d1681b4774adb1422aeed887e6>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in :0
at Cake.Core.Scripting.ScriptHost.RunTarget (System.String target) [0x0000d] in :0
at Submission#0+<>d__0.MoveNext () [0x0018d] in <6462928a9add4807b4daca2876b4797f>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <b64e2aa77b4f4d60b739d6ceaf49caa4>:0 at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState+<RunSubmissionsAsync>d__91[TResult].MoveNext () [0x00186] in <7d37a385ddd24eeb96bd540d739cc157>:0
--- End of stack trace from previous location where exception was thrown ---
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject.Finalize () [0x00000] in :0

0.16.1 breaks build

We' re getting the following error with the new 0.16.1 package:

Could not find any assemblies compatible with .NETFramework,Version=v4.5.
Error: Failed to install addin 'Cake.Git'.

0.16.0 was working fine. Cake version used is 0.21.1.

GitLog returns only one commit when using sinceCommitId

Hi!
Thank you for creating this addin!

It seems, that GitLog(this ICakeContext context, DirectoryPath repositoryDirectoryPath, string sinceCommitId) returns only one commit when it supposed to return all commits between sinceCommitId and HEAD (or maybe I misunderstood the purpose of this method).

If I am right and this is a bug then it could be easily fixed changing CommitFilter from

new CommitFilter
{
    IncludeReachableFrom = sinceCommitId,
    ExcludeReachableFrom = repository.Lookup<Commit>(sinceCommitId).Parents
}

to

new CommitFilter
{
    IncludeReachableFrom = repository.Head,
    ExcludeReachableFrom = repository.Lookup<Commit>(sinceCommitId).Parents
}

and I can submit a PR for this fix.

Push just a develop branch to remote repository

Using GitPush("."); I cannot push develop to remote\develop, the command process all branches. That cause failure The branch 'feature/cakebuild' ("refs/heads/feature/cakebuild") that you are trying to push does not track an upstream branch. in my code.

How process selective push like git push --set-upstream origin develop?

Would it be possible to use the Cake Contrib Icon for your NuGet Package?

Thanks again for creating this Cake Addin, we really appreciate the effort that you have put in to creating it.

We, the Cake Team, recently announced a new Cake Contrib Icon, details of which can be found here:

http://cakebuild.net/blog/2017/06/new-cake-contrib-icon

Would you consider changing the nuspec file for your NuGet Package to use this new Cake Contrib Icon? If so, the recommended URL to use is:

https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png

Details of the above URL can be found in the repository here:

https://github.com/cake-contrib/graphics

Please let me know if you have any questions.

Cake.git addin throw exception in windows 10

ITNOA

Hi,

I have a build.cake like below

#addin nuget:?package=Nuget.Core
#addin nuget:?package=Cake.Git&version=0.19.0
//#addin "nuget:?package=Cake.Coveralls&version=0.9.0"

using NuGet;

var target = Argument("target", "Default");
var artifactsDir = "./artifacts/";
var solutionPath = "../BSN.Commons.sln";
var project = "../Source/BSN.Commons.csproj";
var testFolder = "../Test/BSN.Commons.Tests/";
var testProject = testFolder + "BSN.Commons.Tests.csproj";
var coverageResultsFileName = "coverage.xml";
var currentBranch = Argument<string>("currentBranch", GitBranchCurrent("./").FriendlyName);

Task("Restore")
    .Does(() => {
        DotNetCoreRestore(solutionPath);
});

After i run it by ./build.ps1 -script build.cake --currentBranch=develop --nugetApiKey=g234234 --coverallsToken=234234 --verbosity=Diagnostic, I see below logs

Running build script...
Module directory does not exist.
NuGet.config not found.
Analyzing build script...
Analyzing D:/Users/sooro/Source/Repos/soroshsabz/Commons/Build/build.cake...
Processing build script...
Installing addins...
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/nuget.core/index.json
Found package 'Nuget.Core 2.14.0' in 'D:/Users/sooro/Source/Repos/soroshsabz/Commons/Build/tools/Addins'.
Package NuGet.Core.2.14.0 has already been installed.
Successfully installed 'Nuget.Core 2.14.0' to D:/Users/sooro/Source/Repos/soroshsabz/Commons/Build/tools/Addins
Executing nuget actions took 37.63 ms
The addin Nuget.Core will reference NuGet.Core.dll.
Found package 'Cake.Git 0.19.0' in 'D:/Users/sooro/Source/Repos/soroshsabz/Commons/Build/tools/Addins'.
Package Cake.Git.0.19.0 has already been installed.
Successfully installed 'Cake.Git 0.19.0' to D:/Users/sooro/Source/Repos/soroshsabz/Commons/Build/tools/Addins
Executing nuget actions took 4.37 ms
The addin Cake.Git will reference LibGit2Sharp.dll.
The addin Cake.Git will reference Cake.Git.dll.
Verifying assembly 'NuGet.Core, Version=2.14.0.832, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Verifying assembly 'LibGit2Sharp, Version=0.25.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333'.
Verifying assembly 'Cake.Git, Version=0.19.0.0, Culture=neutral, PublicKeyToken=null'.
Adding assembly reference to mscorlib.dll...
Adding assembly reference to System.Core.dll...
Adding assembly reference to Cake.Core.dll...
Adding assembly reference to Cake.Common.dll...
Adding assembly reference to Cake.exe...
Adding assembly reference to System.dll...
Adding assembly reference to System.Xml.dll...
Adding assembly reference to System.Xml.Linq.dll...
Adding assembly reference to System.Data.dll...
Adding assembly reference to System.Runtime.dll...
Adding assembly reference to System.Collections.dll...
Adding assembly reference to netstandard.dll...
Adding assembly reference to NuGet.Core.dll...
Adding assembly reference to LibGit2Sharp.dll...
Adding assembly reference to Cake.Git.dll...
Importing namespace Cake.Common...
Importing namespace Cake.Common.Build...
Importing namespace Cake.Common.Build.AppVeyor...
Importing namespace Cake.Common.Build.AppVeyor.Data...
Importing namespace Cake.Common.Build.Bamboo...
Importing namespace Cake.Common.Build.Bamboo.Data...
Importing namespace Cake.Common.Build.BitbucketPipelines...
Importing namespace Cake.Common.Build.BitbucketPipelines.Data...
Importing namespace Cake.Common.Build.Bitrise...
Importing namespace Cake.Common.Build.Bitrise.Data...
Importing namespace Cake.Common.Build.ContinuaCI...
Importing namespace Cake.Common.Build.ContinuaCI.Data...
Importing namespace Cake.Common.Build.GitLabCI...
Importing namespace Cake.Common.Build.GitLabCI.Data...
Importing namespace Cake.Common.Build.GoCD...
Importing namespace Cake.Common.Build.GoCD.Data...
Importing namespace Cake.Common.Build.Jenkins...
Importing namespace Cake.Common.Build.Jenkins.Data...
Importing namespace Cake.Common.Build.MyGet...
Importing namespace Cake.Common.Build.TeamCity...
Importing namespace Cake.Common.Build.TFBuild...
Importing namespace Cake.Common.Build.TFBuild.Data...
Importing namespace Cake.Common.Build.TravisCI...
Importing namespace Cake.Common.Build.TravisCI.Data...
Importing namespace Cake.Common.Diagnostics...
Importing namespace Cake.Common.IO...
Importing namespace Cake.Common.IO.Paths...
Importing namespace Cake.Common.Net...
Importing namespace Cake.Common.Security...
Importing namespace Cake.Common.Solution...
Importing namespace Cake.Common.Solution.Project...
Importing namespace Cake.Common.Solution.Project.Properties...
Importing namespace Cake.Common.Solution.Project.XmlDoc...
Importing namespace Cake.Common.Text...
Importing namespace Cake.Common.Tools...
Importing namespace Cake.Common.Tools.Cake...
Importing namespace Cake.Common.Tools.Chocolatey...
Importing namespace Cake.Common.Tools.Chocolatey.ApiKey...
Importing namespace Cake.Common.Tools.Chocolatey.Config...
Importing namespace Cake.Common.Tools.Chocolatey.Download...
Importing namespace Cake.Common.Tools.Chocolatey.Features...
Importing namespace Cake.Common.Tools.Chocolatey.Install...
Importing namespace Cake.Common.Tools.Chocolatey.New...
Importing namespace Cake.Common.Tools.Chocolatey.Pack...
Importing namespace Cake.Common.Tools.Chocolatey.Pin...
Importing namespace Cake.Common.Tools.Chocolatey.Push...
Importing namespace Cake.Common.Tools.Chocolatey.Sources...
Importing namespace Cake.Common.Tools.Chocolatey.Uninstall...
Importing namespace Cake.Common.Tools.Chocolatey.Upgrade...
Importing namespace Cake.Common.Tools.DotCover...
Importing namespace Cake.Common.Tools.DotCover.Analyse...
Importing namespace Cake.Common.Tools.DotCover.Cover...
Importing namespace Cake.Common.Tools.DotCover.Merge...
Importing namespace Cake.Common.Tools.DotCover.Report...
Importing namespace Cake.Common.Tools.DotNetCore...
Importing namespace Cake.Common.Tools.DotNetCore.Build...
Importing namespace Cake.Common.Tools.DotNetCore.Clean...
Importing namespace Cake.Common.Tools.DotNetCore.Execute...
Importing namespace Cake.Common.Tools.DotNetCore.MSBuild...
Importing namespace Cake.Common.Tools.DotNetCore.NuGet.Delete...
Importing namespace Cake.Common.Tools.DotNetCore.NuGet.Push...
Importing namespace Cake.Common.Tools.DotNetCore.Pack...
Importing namespace Cake.Common.Tools.DotNetCore.Publish...
Importing namespace Cake.Common.Tools.DotNetCore.Restore...
Importing namespace Cake.Common.Tools.DotNetCore.Run...
Importing namespace Cake.Common.Tools.DotNetCore.Test...
Importing namespace Cake.Common.Tools.DotNetCore.Tool...
Importing namespace Cake.Common.Tools.DotNetCore.VSTest...
Importing namespace Cake.Common.Tools.DupFinder...
Importing namespace Cake.Common.Tools.Fixie...
Importing namespace Cake.Common.Tools.GitLink...
Importing namespace Cake.Common.Tools.GitReleaseManager...
Importing namespace Cake.Common.Tools.GitReleaseManager.AddAssets...
Importing namespace Cake.Common.Tools.GitReleaseManager.Close...
Importing namespace Cake.Common.Tools.GitReleaseManager.Create...
Importing namespace Cake.Common.Tools.GitReleaseManager.Export...
Importing namespace Cake.Common.Tools.GitReleaseManager.Publish...
Importing namespace Cake.Common.Tools.GitReleaseNotes...
Importing namespace Cake.Common.Tools.GitVersion...
Importing namespace Cake.Common.Tools.ILMerge...
Importing namespace Cake.Common.Tools.ILRepack...
Importing namespace Cake.Common.Tools.InnoSetup...
Importing namespace Cake.Common.Tools.InspectCode...
Importing namespace Cake.Common.Tools.MSBuild...
Importing namespace Cake.Common.Tools.MSpec...
Importing namespace Cake.Common.Tools.MSTest...
Importing namespace Cake.Common.Tools.NSIS...
Importing namespace Cake.Common.Tools.NuGet...
Importing namespace Cake.Common.Tools.NuGet.Add...
Importing namespace Cake.Common.Tools.NuGet.Init...
Importing namespace Cake.Common.Tools.NuGet.Install...
Importing namespace Cake.Common.Tools.NuGet.List...
Importing namespace Cake.Common.Tools.NuGet.Pack...
Importing namespace Cake.Common.Tools.NuGet.Push...
Importing namespace Cake.Common.Tools.NuGet.Restore...
Importing namespace Cake.Common.Tools.NuGet.SetApiKey...
Importing namespace Cake.Common.Tools.NuGet.SetProxy...
Importing namespace Cake.Common.Tools.NuGet.Sources...
Importing namespace Cake.Common.Tools.NuGet.Update...
Importing namespace Cake.Common.Tools.NUnit...
Importing namespace Cake.Common.Tools.OctopusDeploy...
Importing namespace Cake.Common.Tools.OpenCover...
Importing namespace Cake.Common.Tools.ReportGenerator...
Importing namespace Cake.Common.Tools.ReportUnit...
Importing namespace Cake.Common.Tools.Roundhouse...
Importing namespace Cake.Common.Tools.SignTool...
Importing namespace Cake.Common.Tools.SpecFlow...
Importing namespace Cake.Common.Tools.SpecFlow.StepDefinitionReport...
Importing namespace Cake.Common.Tools.SpecFlow.TestExecutionReport...
Importing namespace Cake.Common.Tools.TextTransform...
Importing namespace Cake.Common.Tools.VSTest...
Importing namespace Cake.Common.Tools.VSWhere...
Importing namespace Cake.Common.Tools.VSWhere.All...
Importing namespace Cake.Common.Tools.VSWhere.Latest...
Importing namespace Cake.Common.Tools.VSWhere.Legacy...
Importing namespace Cake.Common.Tools.VSWhere.Product...
Importing namespace Cake.Common.Tools.WiX...
Importing namespace Cake.Common.Tools.WiX.Heat...
Importing namespace Cake.Common.Tools.XBuild...
Importing namespace Cake.Common.Tools.XUnit...
Importing namespace Cake.Common.Xml...
Importing namespace Cake.Core...
Importing namespace Cake.Core.Diagnostics...
Importing namespace Cake.Core.IO...
Importing namespace Cake.Core.Scripting...
Importing namespace Cake.Git...
Importing namespace NuGet...
Importing namespace System...
Importing namespace System.Collections.Generic...
Importing namespace System.IO...
Importing namespace System.Linq...
Importing namespace System.Text...
Importing namespace System.Threading.Tasks...
Compiling build script...
Error: System.AggregateException: One or more errors occurred. ---> System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-6311e88': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path)
   at LibGit2Sharp.Core.Proxy.git_repository_open(String path)
   at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
   at Cake.Git.Extensions.RepositoryExtensions.UseRepository[TResult](ICakeContext context, DirectoryPath repositoryPath, Func`2 repositoryFunc)
   at Cake.Git.GitAliases.GitBranchCurrent(ICakeContext context, DirectoryPath repositoryDirectoryPath)
   at Submission#0.GitBranchCurrent(DirectoryPath repositoryDirectoryPath)
   at Submission#0.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script)
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
   at Cake.Commands.BuildCommand.Execute(CakeOptions options)
   at Cake.CakeApplication.Run(CakeOptions options)
   at Cake.Program.Main()
---> (Inner Exception #0) System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-6311e88': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path)
   at LibGit2Sharp.Core.Proxy.git_repository_open(String path)
   at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
   at Cake.Git.Extensions.RepositoryExtensions.UseRepository[TResult](ICakeContext context, DirectoryPath repositoryPath, Func`2 repositoryFunc)
   at Cake.Git.GitAliases.GitBranchCurrent(ICakeContext context, DirectoryPath repositoryDirectoryPath)
   at Submission#0.GitBranchCurrent(DirectoryPath repositoryDirectoryPath)
   at Submission#0.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()<---

My question is, why throw some exception? and how can i resolved it?

Best regards

Unable to add .

I'm trying to add all pending changes, the equivalent of:

git add .

My repo is in a subdirectory, so I'm doing the following:

GetAdd("./clone", new FilePath[] { "./clone" });

I've tried everything I can think of for the second parameter, all to no avail. With a little playing around I think the issue is with how this relative path is converted.

    var file = File("./clone").Path.MakeAbsolute(Context.Environment);
    var dir = Directory("./clone").Path.MakeAbsolute(Context.Environment);
    Information(dir.GetRelativePath(file).FullPath);

This produces "../clone" rather than ".". Am I missing something obvious, or do we have a bug that needs to be fixed here?

How to define a custom commit message and getting it in GitLogTip?

I am using the following in a build.cake file:

var lastCommit = GitLogTip("My repository path");

Information(@"Last commit {0}
    Short message: {1}
    Author:        {2}
    Authored:      {3:yyyy-MM-dd HH:mm:ss}
    Committer:     {4}
    Committed:     {5:yyyy-MM-dd HH:mm:ss}",
    lastCommit.Sha,
    lastCommit.MessageShort,
    lastCommit.Author.Name,
    lastCommit.Author.When,
    lastCommit.Committer.Name,
    lastCommit.Committer.When
 );

But where does the Message, e.g "Added Travis test folding" comes from?

I am using GitVersion to specify the version and I get the following message in GitLogInfo "Version 1.2.0"

Licensing?

I'm not completely sure, but isn't the resulting nupkg violating the license of libgit? It contains the executables rather than a package dependency.

Add alias for git push with refspec

As part of our build workflow, we push a tag to a remote. Currently, it seems like the Cake.Git only supports pushing branches.

The helper code I wrote to do this looks like the following

static class GitExt {
    public static void Push(DirectoryPath repositoryPath, string remote, string refSpec) {
        using (var repository = new LibGit2Sharp.Repository(repositoryPath.FullPath))
        {
            repository.Network.Push(repository.Network.Remotes[remote], refSpec);
        }
    }
}

The cake build task I use then calls the helper code like below:

Task("Push-Release-Tag")
    .WithCriteria(isReleaseRequested)
    .WithCriteria(!noPush)
    .Does(() => {
        var tagVersion = "v" + releaseVersion;
        string gitRemote = "origin";
        Information("Pushing new tag to {0}", gitRemote);
        GitExt.Push(".", gitRemote, "refs/tags/" + tagVersion);
    });

This seems like the type of thing that would be useful to include with the Cake.Addin, would this be something that could be added?

Tests for new alias methods cannot run with cake >= 0.26

While writing some additional alias methods for git tags, I detected the issue with the new version of cake 0.26. If the test runs with the previous used version 0.22 all tests passed.

After a rebase to master the test fails because the new alias method could not be found. The version 0.26.1 does not fix this issue.

When the test.cake file is executed, cake restores the Cake_Git package from the configured nuget feeds.

Issue with accessing Tag properties

Hey @devlead,

When I try and get tags using the following:

    #addin "nuget:?package=Cake.Git"

    var tags = GitTags(DirectoryPath.FromString("../"));

I get a list of tags, but when I try and access the .Target property

Information($"The version of this project is {packageVersion} - {tag.FriendlyName} - {tag.Reference} - {tag.Target}");

I get the following exception:

Cake.exe : 
At C:\ClickView Projects\HomeMigrator\build\build.ps1:235 char:1
+ &$CAKE_EXE $cakeArguments
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
Unhandled Exception: 
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at LibGit2Sharp.Core.NativeMethods.git_object_lookup(git_object*& obj, git_repository* repo, GitOid& id, GitObjectType type)
   at LibGit2Sharp.Core.Proxy.git_object_lookup(RepositoryHandle repo, ObjectId id, GitObjectType type) in C:\git\libgit2sharp\LibGit2Sharp.Shared\Core\Proxy.cs:line 1455
   at LibGit2Sharp.Repository.LookupInternal(ObjectId id, GitObjectType type, FilePath knownPath) in C:\git\libgit2sharp\LibGit2Sharp.Shared\Repository.cs:line 532
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at LibGit2Sharp.ReferenceWrapper`1.RetrieveTargetObject(Reference reference) in C:\git\libgit2sharp\LibGit2Sharp.Shared\ReferenceWrapper.cs:line 107
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at LibGit2Sharp.Tag.get_Target() in C:\git\libgit2sharp\LibGit2Sharp.Shared\Tag.cs:line 34
   at Submission#0.<<Initialize>>b__0_2()
   at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass20_0.<Does>b__0(ICakeContext x)
   at Cake.Core.CakeTask.<Execute>d__43.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Cake.Core.CakeTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.<ExecuteAsync>d__4.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Cake.Core.DefaultExecutionStrategy.ExecuteAsync(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.<RunTask>d__28.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Cake.Core.CakeEngine.RunTask(ICakeContext context, IExecutionStrategy strategy, CakeTask task, String target, Stopwatch stopWatch, CakeReport report)
   at Cake.Core.CakeEngine.<RunTargetAsync>d__27.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Cake.Core.CakeEngine.RunTargetAsync(ICakeContext context, IExecutionStrategy strategy, ExecutionSettings settings)
   at Cake.Scripting.BuildScriptHost.<RunTargetAsync>d__3.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Cake.Scripting.BuildScriptHost.RunTargetAsync(String target)
   at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
   at Submission#0.<<Initialize>>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Submission#0.<Initialize>()
   at Submission#0.<Factory>(Object[] submissionArray)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 
exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.CodeAnalysis.Scripting.Script`1.RunSubmissionsAsync(ScriptExecutionState executionState, ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, 
Func`2 catchExceptionOpt, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Script`1.RunAsync(Object
 globals, Func`2 catchException, CancellationToken cancellationToken)
   at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script)
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
   at Cake.Commands.BuildCommand.Execute(CakeOptions options)
   at Cake.CakeApplication.Run(CakeOptions options)
   at Cake.Program.Main()

Am I doing somethign wrong or this a bug? I am running the latest from nuget (0.18.0). Really appreciate all the great work on this project, thanks in advance!

Will no longer work with latest cake.

Error: The assembly 'Cake.Git, Version=0.16.1.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.22.0). 
This assembly need to reference at least Cake.Core version 0.26.0. 
Another option is to downgrade Cake to an earlier version. 
It's not recommended, but you can explicitly opt-out of assembly verification 
by configuring the Skip Verification setting to true
(i.e. command line parameter "--settings_skipverification=true", 
environment variable "CAKE_SETTINGS_SKIPVERIFICATION=true", 
read more about configuration at https://cakebuild.net/docs/fundamentals/configuration)
Command exited with code 1

Recommended changes resulting from automated audit

We performed an automated audit of your Cake addin and found that it does not follow all the best practices.

We encourage you to make the following modifications:

  • You are currently referencing Cake.Core 0.26.0. Please upgrade to 0.28.0
  • Your addin should target netstandard2.0. Please note that there is no need to multi-target, netstandard2.0 is sufficient.

Apologies if this is already being worked on, or if there are existing open issues, this issue was created based on what is currently published for this package on NuGet.org and in the project on github.

GitDiff Two Commits in a specific folder

Hi,
Is it possible to specify a specific folder (that isn't the repository path) when diffing 2 commits?
From what I understand I have to put the repository path .

Thank you,
Shani

Cake Script Fails to install Cake.Git

I keep getting the error "Could not find any assemblies compatible with .NETFramework,Version=4.5 Error: Failed to install addin 'Cake.Git'"

I've tried a number of different things already including fixed versions of the addin, and trying to use previous releases. Nothing changes.

Any hints for me?

Exception on OS X

Seems lib2git does not play nice with OS X :(

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: git2-785d8c4

Mono, version
Mono JIT compiler version 4.2.3 (explicit/832de4b Thu Mar 3 19:24:57 EST 2016)

Provide an alias to retrieve the short format of a SHA1

Provided a Commit object, I'd like to be able to retrieve the short version of its Sha.

Hypothetical example:

var commit = GitLogTip("path/to/repo");
var shortSha = GitShortenSha(commit);
// or
var shortSha = GitShortenSha(commit.Sha);

The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception

Hi there

Im using package=Cake.Git on my cake script.... and it works on my machine :) but when I execute my build in my Jenkins CI it happens an error during script execution reporting an error with this log: "The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception".
My Cake.Git package version is the lastest Cake.Git.0.19.0 and the agent OS is Microsoft Windows Server Version 1607 (OS Build 14393.2485).

Does anyone knows anything about this ?

Add alias for git tag

Our release process, we use git tag to create a tag from the release was deployed from.

Is it possible to add a new alias for tagging?

Exception TargetInvocationException in GitTags(..)

Hi,
I get exception TargetInvocationException in GitTags(".");
I using Windows 10 x64, Cake.0.25.0, Cake.Git.0.16.1.

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at LibGit2Sharp.Core.NativeMethods.git_object_lookup(git_object*& obj, git_repository* repo, GitOid& id, GitObjectType type) at LibGit2Sharp.Core.Proxy.git_object_lookup(RepositoryHandle repo, ObjectId id, GitObjectType type) in C:\git\libgit2sharp\LibGit2Sharp.Shared\Core\Proxy.cs:line 1455 at LibGit2Sharp.Repository.LookupInternal(ObjectId id, GitObjectType type, FilePath knownPath) in C:\git\libgit2sharp\LibGit2Sharp.Shared\Repository.cs:line 532 at System.Lazy1.CreateValue()
at System.Lazy1.LazyInitValue() at LibGit2Sharp.ReferenceWrapper1.RetrieveTargetObject(Reference reference) in C:\git\libgit2sharp\LibGit2Sharp.Shared\ReferenceWrapper.cs:line 107
at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue()
at LibGit2Sharp.Tag.get_Annotation() in C:\git\libgit2sharp\LibGit2Sharp.Shared\Tag.cs:line 24
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.SecurityUtils.MethodInfoInvoke(MethodInfo method, Object target, Object[] args)
at System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)
at Cake.Incubator.LoggingExtensions.ObjectToString[T](T obj) in C:\projects\cake-incubator\src\Cake.Incubator\LoggingExtensions.cs:line 86
at Cake.Incubator.LoggingExtensions.Dump[T](T obj) in C:\projects\cake-incubator\src\Cake.Incubator\LoggingExtensions.cs:line 70
at Submission#0.<>b__0_0(ICakeContext context)
at Cake.Core.DefaultExecutionStrategy.PerformSetup(Action1 action, ICakeContext context) in C:\projects\cake\src\Cake.Core\DefaultExecutionStrategy.cs:line 44 at Cake.Core.CakeEngine.PerformSetup(IExecutionStrategy strategy, ICakeContext context) in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 209 at Cake.Core.CakeEngine.<RunTargetAsync>d__18.MoveNext() in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 135 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine& stateMachine)
at Cake.Core.CakeEngine.RunTargetAsync(ICakeContext context, IExecutionStrategy strategy, String target)
at Cake.Scripting.BuildScriptHost.d__3.MoveNext() in C:\projects\cake\src\Cake\Scripting\BuildScriptHost.cs:line 44
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine& stateMachine) at Cake.Scripting.BuildScriptHost.RunTargetAsync(String target) at Cake.Core.Scripting.ScriptHost.RunTarget(String target) in C:\projects\cake\src\Cake.Core\Scripting\ScriptHost.cs:line 173 at Submission#0.<<Initialize>>d__0.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine& stateMachine)
at Submission#0.()
at Submission#0.(Object[] submissionArray)
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.d__91.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray1 precedingExecutors, Func2 currentExecutor, StrongBox1 exceptionHolderOpt, Func2 catchExceptionOpt, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Scripting.Script1.<RunSubmissionsAsync>d__21.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.CodeAnalysis.Scripting.Script1.RunSubmissionsAsync(ScriptExecutionState executionState, ImmutableArray1 precedingExecutors, Func2 currentExecutor, Func2 catchExceptionOpt, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Scripting.Script1.RunAsync(Object globals, Func2 catchException, CancellationToken cancellationToken)
at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script) in C:\projects\cake\src\Cake\Scripting\Roslyn\RoslynScriptSession.cs:line 127
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary2 arguments) in C:\projects\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 212 at Cake.Commands.BuildCommand.Execute(CakeOptions options) in C:\projects\cake\src\Cake\Commands\BuildCommand.cs:line 35 at Cake.CakeApplication.Run(CakeOptions options) in C:\projects\cake\src\Cake\CakeApplication.cs:line 45 at Cake.Program.Main() in C:\projects\cake\src\Cake\Program.cs:line 74

Target netstandard2.0 to run with Cake.CoreCLR

It would be cool, if the Cake.CoreCLR compatibility could be added, as stated here:
https://cakebuild.net/blog/2018/02/cake-v0.26.0-released
Due to this only "netstandard2.0" needs to be targeted by the addin.

The error, which appeared to me relating to this issue was a known one: "Error: Failed to install addin 'Cake.Git'."
This misleading message lead me to: cake-build/cake#2011 ... but that's another thing...

Thanks for your support and your great work!

Linux (Ubuntu): LibGit2Sharp failing with "System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so"

It's related to #61 but in my case it's happening on Ubuntu Xenial (not CentOS).

I have a Docker container with TeamCity agent (FROM jetbrains/teamcity-agent) where I run my build with Cake 0.25.0. Cake script has import #addin "Cake.Git".
Previously it worked fine. But yesterday I rebuilt the container to update it to using .net core 2.1 and my builds start failing.

The error is pretty typical for LibGit2Sharp - DllNotFoundException for lib/linux/x86_64/libgit2-1196807.so
I checked that that module (libgit2-1196807.so) exists in Cake's tools dir, it does:
/opt/buildagent/work/e1fb3d71588668ec/Build/tools/Addins/cake.git/Cake.Git/lib/net46/lib/linux/x86_64/libgit2-1196807.so

But it looks suspicious that the package is installed into net46 folder.

The error:

[19:52:42][Step 1/2] Installing Cake 0.25.0...
[19:53:30][Step 1/2] Error: One or more errors occurred.
[19:53:30][Step 1/2] 	The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
[19:53:30][Step 1/2] 
[19:53:30][Step 1/2] Unhandled Exception:
[19:53:30][Step 1/2] System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
[19:53:30][Step 1/2]   at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]    --- End of inner exception stack trace ---
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00008] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options, LibGit2Sharp.Repository+RepositoryRequiredParameter requiredParameter) [0x00312] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Repository..ctor (System.String path) [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at Cake.Git.Extensions.RepositoryExtensions.UseRepository[TResult] (Cake.Core.ICakeContext context, Cake.Core.IO.DirectoryPath repositoryPath, System.Func`2[T,TResult] repositoryFunc) [0x00061] in <68d0f59d618141b69437a5843a3bbe02>:0 
[19:53:30][Step 1/2]   at Cake.Git.GitAliases.GitBranchCurrent (Cake.Core.ICakeContext context, Cake.Core.IO.DirectoryPath repositoryDirectoryPath) [0x0001c] in <68d0f59d618141b69437a5843a3bbe02>:0 
[19:53:30][Step 1/2]   at Submission#0.GitBranchCurrent (Cake.Core.IO.DirectoryPath repositoryDirectoryPath) [0x0000c] in <1937edc4fc034377b66b7353cb660d87>:0 
[19:53:30][Step 1/2]   at Submission#0+<<Initialize>>d__0.MoveNext () [0x0058f] in <1937edc4fc034377b66b7353cb660d87>:0 
[19:53:30][Step 1/2] --- End of stack trace from previous location where exception was thrown ---
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState+<RunSubmissionsAsync>d__9`1[TResult].MoveNext () [0x00186] in <7d37a385ddd24eeb96bd540d739cc157>:0 
[19:53:30][Step 1/2] --- End of stack trace from previous location where exception was thrown ---
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject.Finalize () [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2] [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
[19:53:30][Step 1/2]   at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]    --- End of inner exception stack trace ---
[19:53:30][Step 1/2]   at LibGit2Sharp.Core.Proxy.git_repository_open (System.String path) [0x00008] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Repository..ctor (System.String path, LibGit2Sharp.RepositoryOptions options, LibGit2Sharp.Repository+RepositoryRequiredParameter requiredParameter) [0x00312] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at LibGit2Sharp.Repository..ctor (System.String path) [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0 
[19:53:30][Step 1/2]   at Cake.Git.Extensions.RepositoryExtensions.UseRepository[TResult] (Cake.Core.ICakeContext context, Cake.Core.IO.DirectoryPath repositoryPath, System.Func`2[T,TResult] repositoryFunc) [0x00061] in <68d0f59d618141b69437a5843a3bbe02>:0 
[19:53:30][Step 1/2]   at Cake.Git.GitAliases.GitBranchCurrent (Cake.Core.ICakeContext context, Cake.Core.IO.DirectoryPath repositoryDirectoryPath) [0x0001c] in <68d0f59d618141b69437a5843a3bbe02>:0 
[19:53:30][Step 1/2]   at Submission#0.GitBranchCurrent (Cake.Core.IO.DirectoryPath repositoryDirectoryPath) [0x0000c] in <1937edc4fc034377b66b7353cb660d87>:0 
[19:53:30][Step 1/2]   at Submission#0+<<Initialize>>d__0.MoveNext () [0x0058f] in <1937edc4fc034377b66b7353cb660d87>:0 
[19:53:30][Step 1/2] --- End of stack trace from previous location where exception was thrown ---
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:30][Step 1/2]   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <71d8ad678db34313b7f718a414dfcb25>:0 
[19:53:31][Step 1/2]   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState+<RunSubmissionsAsync>d__9`1[TResult].MoveNext () [0x00186] in <7d37a385ddd24eeb96bd540d739cc157>:0 
[19:53:31][Step 1/2] --- End of stack trace from previous location where exception was thrown ---
[19:53:31][Step 1/2]   at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject.Finalize () [0x00000] in <c31a5a5a3e0a424683609ecf6c55de77>:0 

Native DLL not found on Ubuntu

Hello,
I'm trying to run a build script that uses this addin, although it works on Windows, I'm not able to use it on Ubuntu, the error says:

'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: git2-381caf5

There is a file named libgit2-381caf5.so in the tools/Addins/Cake.Git/lib/linux/x86_64 folder, is this a naming inconsistency issue? Am I missing something?

Thank you

GitClones throws "Method has no body"

Running the following task throws an exception BadImageFormatException: Method has no body:

Task("CloneTest")
    .Does(() =>
{
    GitClone("https://github.com/cake-build/cake.git", "/tmp/cake");
});

I am using Fedora 28 with Mono 5.14 and Cake 0.30.

Error: System.AggregateException: One or more errors occurred. ---> System.BadImageFormatException: Method has no body
  at LibGit2Sharp.Core.Proxy.git_clone (System.String url, System.String workdir, LibGit2Sharp.Core.GitCloneOptions& opts) [0x00009] in <b59d5da32f8541b2a767004d8bddc22b>:0
  at LibGit2Sharp.Repository.Clone (System.String sourceUrl, System.StringworkdirPath, LibGit2Sharp.CloneOptions options) [0x000d3] in <b59d5da32f8541b2a767004d8bddc22b>:0
  at LibGit2Sharp.Repository.Clone (System.String sourceUrl, System.StringworkdirPath) [0x00000] in <b59d5da32f8541b2a767004d8bddc22b>:0
  at Cake.Git.GitAliases.GitClone (Cake.Core.ICakeContext context, System.String sourceUrl, Cake.Core.IO.DirectoryPath workDirectoryPath) [0x000d2] in <7958095920474dc68d0a782f46e32170>:0
  at Submission#0.GitClone (System.String sourceUrl, Cake.Core.IO.DirectoryPath workDirectoryPath) [0x0000c] in <206e5fefce8d49f39d9236778bce09b0>:0
  at Submission#0.<<Initialize>>b__0_4 () [0x00011] in <206e5fefce8d49f39d9236778bce09b0>:0
  at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass17_0.<Does>b__0 (Cake.Core.ICakeContext context) [0x00000] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
  at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass20_0.<Does>b__0 (Cake.Core.ICakeContext x) [0x00000] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
  at Cake.Core.CakeTask+<Execute>d__43.MoveNext () [0x00066] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.DefaultExecutionStrategy+<ExecuteAsync>d__4.MoveNext () [0x000ee] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.CakeEngine+<ExecuteTaskAsync>d__31.MoveNext () [0x00131] in<1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.CakeEngine+<RunTask>d__28.MoveNext () [0x00124] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.CakeEngine+<RunTargetAsync>d__27.MoveNext () [0x00338] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Scripting.BuildScriptHost+<RunTargetAsync>d__3.MoveNext () [0x0009f] in <52bc22bce5254240ba373b3cf23da1ab>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.Scripting.ScriptHost.RunTarget (System.String target) [0x0000d] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
  at Submission#0+<<Initialize>>d__0.MoveNext () [0x00195] in <206e5fefce8d49f39d9236778bce09b0>:0
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState+<RunSubmissionsAsync>d__9`1[TResult].MoveNext () [0x00186] in <3ee4bd870c1146d59b98317e4bbdcbe8>:0
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.CodeAnalysis.Scripting.Script`1+<RunSubmissionsAsync>d__21[T].MoveNext () [0x000a8] in <3ee4bd870c1146d59b98317e4bbdcbe8>:0
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <b78dcefd6c184245be8bf4a1e52466d9>:0
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <b78dcefd6c184245be8bf4a1e52466d9>:0
  at System.Threading.Tasks.Task.Wait () [0x00000] in <b78dcefd6c184245be8bf4a1e52466d9>:0
  at Cake.Scripting.Roslyn.RoslynScriptSession.Execute (Cake.Core.Scripting.Script script) [0x001a7] in <52bc22bce5254240ba373b3cf23da1ab>:0
  at Cake.Core.Scripting.ScriptRunner.Run (Cake.Core.Scripting.IScriptHosthost, Cake.Core.IO.FilePath scriptPath, System.Collections.Generic.IDictionary`2[TKey,TValue] arguments) [0x00358] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
  at Cake.Commands.BuildCommand.Execute (Cake.CakeOptions options) [0x0003f] in <52bc22bce5254240ba373b3cf23da1ab>:0
  at Cake.CakeApplication.Run (Cake.CakeOptions options) [0x00015] in <52bc22bce5254240ba373b3cf23da1ab>:0
  at Cake.Program.Main () [0x000d1] in <52bc22bce5254240ba373b3cf23da1ab>:0
---> (Inner Exception #0) System.BadImageFormatException: Method has no body
File name: 'LibGit2Sharp'
  at LibGit2Sharp.Core.Proxy.git_clone (System.String url, System.String workdir, LibGit2Sharp.Core.GitCloneOptions& opts) [0x00009] in <b59d5da32f8541b2a767004d8bddc22b>:0
  at LibGit2Sharp.Repository.Clone (System.String sourceUrl, System.StringworkdirPath, LibGit2Sharp.CloneOptions options) [0x000d3] in <b59d5da32f8541b2a767004d8bddc22b>:0
  at LibGit2Sharp.Repository.Clone (System.String sourceUrl, System.StringworkdirPath) [0x00000] in <b59d5da32f8541b2a767004d8bddc22b>:0
  at Cake.Git.GitAliases.GitClone (Cake.Core.ICakeContext context, System.String sourceUrl, Cake.Core.IO.DirectoryPath workDirectoryPath) [0x000d2] in <7958095920474dc68d0a782f46e32170>:0
  at Submission#0.GitClone (System.String sourceUrl, Cake.Core.IO.DirectoryPath workDirectoryPath) [0x0000c] in <206e5fefce8d49f39d9236778bce09b0>:0
  at Submission#0.<<Initialize>>b__0_4 () [0x00011] in <206e5fefce8d49f39d9236778bce09b0>:0
  at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass17_0.<Does>b__0 (Cake.Core.ICakeContext context) [0x00000] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
  at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass20_0.<Does>b__0 (Cake.Core.ICakeContext x) [0x00000] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
  at Cake.Core.CakeTask+<Execute>d__43.MoveNext () [0x00066] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.DefaultExecutionStrategy+<ExecuteAsync>d__4.MoveNext () [0x000ee] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.CakeEngine+<ExecuteTaskAsync>d__31.MoveNext () [0x00131] in<1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.CakeEngine+<RunTask>d__28.MoveNext () [0x00124] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.CakeEngine+<RunTargetAsync>d__27.MoveNext () [0x00338] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Scripting.BuildScriptHost+<RunTargetAsync>d__3.MoveNext () [0x0009f] in <52bc22bce5254240ba373b3cf23da1ab>:0
--- End of stack trace from previous location where exception was thrown ---
  at Cake.Core.Scripting.ScriptHost.RunTarget (System.String target) [0x0000d] in <1a12afcf649f4de8ab5d15d82d4f6310>:0
  at Submission#0+<<Initialize>>d__0.MoveNext () [0x00195] in <206e5fefce8d49f39d9236778bce09b0>:0
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState+<RunSubmissionsAsync>d__9`1[TResult].MoveNext () [0x00186] in <3ee4bd870c1146d59b98317e4bbdcbe8>:0
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.CodeAnalysis.Scripting.Script`1+<RunSubmissionsAsync>d__21[T].MoveNext () [0x000a8] in <3ee4bd870c1146d59b98317e4bbdcbe8>:0 <---

Add XML doc sample code for Branch aliases

For better documentation on cakebuild.net add example code to GitBranch, examples/usage can probably be found in the integration tests.

Example how to XML doc see example tag below

        /// <summary>
        /// Retrieves the value of the environment variable or <c>null</c> if the environment variable does not exist.
        /// </summary>
        /// <example>
        /// <code>
        /// Information(EnvironmentVariable("HOME") ?? "Unknown location");
        /// </code>
        /// </example>
        /// <param name="context">The context.</param>
        /// <param name="variable">The environment variable.</param>
        /// <returns>The environment variable or <c>null</c> if the environment variable does not exist.</returns>

Add XML doc sample code for Add aliases

For better documentation on cakebuild.net add example code to GitAdd, examples/usage can probably be found in the integration tests.

Example how to XML doc see example tag below

        /// <summary>
        /// Retrieves the value of the environment variable or <c>null</c> if the environment variable does not exist.
        /// </summary>
        /// <example>
        /// <code>
        /// Information(EnvironmentVariable("HOME") ?? "Unknown location");
        /// </code>
        /// </example>
        /// <param name="context">The context.</param>
        /// <param name="variable">The environment variable.</param>
        /// <returns>The environment variable or <c>null</c> if the environment variable does not exist.</returns>

Git Stage is missing

git stage is missing. We do have its synonym git add. Would be best of we could add stage that too.

Build errors for .NET 4.5

Hi, I guess .net 4.5 support was removed recently or something? Breaking change?

λ build
Preparing to run build script...
Running build script...
Analyzing build script...
Processing build script...
Installing tools...
Installing addins...
Could not find any assemblies compatible with .NETFramework,Version=v4.5.
Error: Failed to install addin 'Cake.Git'.

Add alias for git fetch

In particular, having an alias for git fetch --tags would help workaround an issue with TeamCity not fetching tags when that's the only change.

References:

missing netstandard

I'm getting following error with new version on my build server (teamcity).
But version 0.18.0 seems to work flawless.

my build.cake file includes nuget packages:
#tool nuget:?package=OctopusTools&version=4.21.0
#tool nuget:?package=GitVersion&version=3.6.5
#tool "nuget:?package=GitVersion.CommandLine"
#addin nuget:?package=Cake.Git&version=0.18.0

tools\Addins\Cake.Git.0.19.0\lib\net461\Cake.Git.dll (missing netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
tools\Addins\Cake.Git.0.19.0\lib\net461\LibGit2Sharp.dll (missing netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)

Error when running on TeamCity

Hi,

Getting the following build error when trying to run GitBranchCurrent on TeamCity, but not locally.

Error: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
[10:57:23][Step 1/1] Unhandled Exception: System.TypeInitializationException: 
The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. 
---> System.DllNotFoundException: 
Unable to load DLL 'git2-1196807': The specified module could not be found. 
(Exception from HRESULT: 0x8007007E)

Any workaround..?

Log and describe don't work correctly

There is a simple command in git to get every commit since previous tags, something that is useful when creating release notes:

git log $(git describe --tags --abbrev=0)..HEAD --oneline

The equivalent code for Cake.Git would be

GitLog(rootDir, GitDescribe(rootDir,  GitDescribeStrategy.Tags));

Unfortunately this does not produce the same result. From the source code it looks like it uses a simple linq expression that stops when it finds the tag, while the libgit2sharp documentation recommends a different way to do it. For example, given the following git history:

        * - HEAD - merge
        |\
        | * - commit1
        | |
        | * - commit2
 Tag2 - * |
        |/
        * - Tag1
        |

The command line snippet above lists three lines, the merge, commit1 and commit2, but Cake.Git only lists the merge commit, since it stops when the linq expression reaches the first tag.

If Cake.Git instead use ExcludeReachableFrom as described in the libgit2sharp documentation it would produce the correct output.

Provide an overload to push to untracked refSpecs

I am executing the following command on a Cake build script:
GitPush(".", "username", "password", "master");

And I get the following error:
LibGit2Sharp.LibGit2SharpException: The branch 'master' ("refs/heads/master") that you are trying to push does not track an upstream branch.

After it I just run it manually on the command line using:
git push origin master

And in this case it is pushed. What might be wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.