Skip to content

Additional Git functionality like change detection for Cake scripts

License

Notifications You must be signed in to change notification settings

hoffmann-dsd/cake-git-ext-plugin

Repository files navigation

cake-git-ext-plugin

GitHub license

Overview

CakeExt.Git is a set of Cake build script extensions that provide additional functionality for working with Git commands beyond what is included in the Cake.Git extension. These extensions aim to simplify the integration of Git-related tasks, especially for handling of changes between two commits into your Cake build scripts.

Git

Executes a Git command and returns the output as an IEnumerable.

ICakeContext context;

var output = context.Git("your-git-command-here");

GitGetLastCommitMessage

Returns the last commit message as a string.

ICakeContext context;

var lastCommitMessage = context.GitGetLastCommitMessage();

GitGetBranchName

Gets the current branch name.

ICakeContext context;

var branchName = context.GitGetBranchName();

Change Detection

GitMergeBase

Gets the merge base between the current branch and a specified remote branch.

If the current branch is the main branch, the merge base is the latest commit on the remote branch. If the current branch is not the main branch, the merge base is the latest commit on the main branch that is also on the current branch.

ICakeContext context;

var mergeBase = context.GitMergeBase("your-remote", "your-main-branch");

GitRevHead

Gets the revision head commit id.

ICakeContext context;

var revHead = context.GitRevHead();

GitDiff

Gets the filenames of the changes between two commits.

ICakeContext context;

var changes = context.GitDiff("commit-hash-1", "commit-hash-2");

GitGetChanges

Gets the changed files between the current commit and the merge base.

ICakeContext context;

var changes = context.GitGetChanges("your-remote", "your-main-branch");

GitGetChangeMatchPattern

Checks if any of the changed files match a given regex pattern.

ICakeContext context;
var hasMatch = context.GitGetChangeMatchPattern(changes, "your-regex-pattern");

Usage

The package is published to the GitHub Packages NuGet registry. To use the package in your Cake build script project, you must add the GitHub Packages NuGet registry to your Cake build script project's NuGet.config file. For more information, see the following link:

https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry#installing-a-package

Add the CakeExt.Git NuGet package to your Cake build script project.

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

Import the namespace in your Cake build script.

using CakeExt.Git;

Use the provided aliases in your Cake build script as needed.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Additional Git functionality like change detection for Cake scripts

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •  

Languages