public static string GitDescribe( this ICakeContext context, DirectoryPath repositoryDirectoryPath, bool renderLongFormat, GitDescribeStrategy strategy, int?minimumCommitIdAbbreviatedSize) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (repositoryDirectoryPath == null) { throw new ArgumentNullException(nameof(repositoryDirectoryPath)); } return(context.UseRepository( repositoryDirectoryPath, repository => GitDescribeImpl(context, repository, repository.Head.Commits.First(), renderLongFormat, strategy, minimumCommitIdAbbreviatedSize))); }
public static string GitDescribe( this ICakeContext context, DirectoryPath repositoryDirectoryPath, GitDescribeStrategy strategy) { return(GitDescribe(context, repositoryDirectoryPath, renderLongFormat: false, strategy: strategy, minimumCommitIdAbbreviatedSize: null)); }
private static DescribeStrategy ConvertDescribeStrategy(GitDescribeStrategy source) { switch (source) { case GitDescribeStrategy.Default: return(DescribeStrategy.Default); case GitDescribeStrategy.Tags: return(DescribeStrategy.Tags); case GitDescribeStrategy.All: return(DescribeStrategy.All); default: throw new ArgumentOutOfRangeException(nameof(source), source, "Unknown git describe strategy"); } }
private static string GitDescribeImpl( ICakeContext context, IRepository repository, Commit commit, bool renderLongFormat, GitDescribeStrategy strategy, int?minimumCommitIdAbbreviatedSize) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (commit == null) { throw new ArgumentNullException(nameof(commit)); } try { var describeOptions = new DescribeOptions { AlwaysRenderLongFormat = renderLongFormat, Strategy = ConvertDescribeStrategy(strategy) }; if (minimumCommitIdAbbreviatedSize.HasValue) { describeOptions.MinimumCommitIdAbbreviatedSize = minimumCommitIdAbbreviatedSize.Value; } return(repository.Describe(commit, describeOptions)); } catch (Exception ex) { context.Log.Warning(Verbosity.Normal, "Describe failed, empty string returned:\n{0}", ex); return(""); } }
public static string GitDescribe( this ICakeContext context, DirectoryPath repositoryDirectoryPath, string commitishName, bool renderLongFormat, GitDescribeStrategy strategy, int?minimumCommitIdAbbreviatedSize) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (repositoryDirectoryPath == null) { throw new ArgumentNullException(nameof(repositoryDirectoryPath)); } if (commitishName == null) { throw new ArgumentNullException(nameof(commitishName)); } return(context.UseRepository( repositoryDirectoryPath, repository => { var commit = repository.Lookup(commitishName, ObjectType.Commit) as Commit; if (commit == null) { throw new NotFoundException("Commit not found: " + commitishName); } return GitDescribeImpl(context, repository, commit, renderLongFormat, strategy, minimumCommitIdAbbreviatedSize); })); }