Giter Site home page Giter Site logo

ps-githubpullrequest's Introduction

PS-GitHubPullRequest

A PowerShell tool to interact with the GitHub API and watch/resolve pull requests using your own logic. More information about why I made this can be found on my blog.

Functionality:

  • List the pull request from within a Git repository
  • Show the diff displaying the changes
  • Resolve the pull request using your own logic
  • Create a new pull request for the branch you are currently on

Read-PullRequest

This will output a list containing the current open pull requests for the current repository if any. When selecting one it will open your difftool showing the changes compared to the base branch.

New-PullRequest -title 'Insert your title here'

Create a new pull request for the branch you are currently on. Requires a title as parameter. If no base branch is given, it will use the one defined in $GitHubPullRequestSettings.BaseBranch. Options:

  • -base: the branch you want to merge into (string)
  • -head: the branch you want to merge (string)
  • -body: additional content (string)
  • -assignee: GitHub username (string)

Close-PullRequest

List the pull request and close it using git merge <branchname> --ff-only. If you need a different merge strategy, you can create a new use for the Invoke-MergeLogic function in your Microsoft.PowerShell_profile.ps1 file:

function Invoke-MergeLogic
{
  param(
    [Parameter(Mandatory = $true)]
    [object]
    $pullRequest
  )
  Write-Host 'Hello from my settings!'
}

The function receives an object called pullRequest as parameter. This object is the parsed content of the json reponse received from the GitHub API containing your selected pull request as described in the GitHub documentation.

Prerequisites

Make sure you have Posh-Git installed. I do this using PsGet :

Install-Module posh-git

The console experience used in the screenshots is PS-Agnoster, you can find more information here.

Installing

Adjust your Microsoft.PowerShell_profile.ps1 file to include both Posh-Git and PS-GitHubPullRequest. Make sure the Posh-Git module is sourced before you source PS-GitHubPullRequest.

This example assumes the location of PS-GitHubPullRequest is in the Github folder, adjust to your needs.

Import-Module -Name posh-git -ErrorAction SilentlyContinue
. "$env:USERPROFILE\Github\PS-GitHubPullRequest\PS-GitHubPullRequest.ps1"

Configuration

List the current configuration:

$GitHubPullRequestSettings

You can tweak the settings by manipulating $GitHubPullRequestSettings. This example allows you to tweak the base branch:

$GitHubPullRequestSettings.BaseBranch = 'develop'

ps-githubpullrequest's People

Contributors

jandedobbeleer avatar janjoris avatar

Watchers

 avatar  avatar

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.