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

add command for describe git repository #3

Closed halex2005 closed 8 years ago

halex2005 commented 8 years ago

Hello!

I'd like to use Cake.Git tool in by build scripts. We have versioning scheme based on tagging our branches with version number (like v1.0.0). I'd like to receive current tag name in build scripts.

This can be done with git describe --tags command line. I found that libgit2sharp already have implemented Describe() method (see this closed issue).

Please, consider to accept this PR. Also I guess, this implementation can be improved by passing Commit as parameter. What do you think?

/cc:@devlead

halex2005 commented 8 years ago

So, without this PR I have workaround like:

var processSettings = new ProcessSettings()
    .SetRedirectStandardOutput(true)
    .WithArguments(x => {
        x.Append("describe")
            .Append("--tags")
            .AppendSwitch("--match", "versions/*")
            .Append("--abbrev=0");
    });
using (var describeProcess = StartAndReturnProcess("git", processSettings))
{
    describeProcess.WaitForExit();
    var lines = describeProcess.GetStandardOutput().ToList();
    if (lines.Count == 0 || lines.Count > 1)
    {
        Warning("git describe returns no tags [{0}]", string.Join("\n", lines));
        return null;
    }
    lastestTag = lines.FirstOrDefault();
}

instead of one line using PR:

lastestTag = GitDescribe(".", GitDescribeStrategy.Tags);
devlead commented 8 years ago

Hi @halex2005,

Sorry we've been very busy with other projects, we'll review this PR as soon as possible. If possible please add a test case too test.cake

devlead commented 8 years ago

Left some minor comments, will review more tomorrow. If possible please add example code to the aliases too you can read more about it here

halex2005 commented 8 years ago

Also added git describe specified commit, not only head. Review, please.

devlead commented 8 years ago

@halex2005 Currently exceptions are swallowed and test aren't failed just logged, throw in tasks if unexpected result is returned see build log https://ci.appveyor.com/project/WCOMAB/cake-git/build/0.2.0-build-0125#L401

halex2005 commented 8 years ago

It seems I'm done. Thanks for your review!

devlead commented 8 years ago

Could you please rebase into one commit and I'll do a final review before merging.

halex2005 commented 8 years ago

Made one commit

devlead commented 8 years ago

@halex2005 LGTM:+1: merged! thanks for your contribution.

halex2005 commented 8 years ago

Thanks for feedback and merging! That was awesome experience for me!