Skip to content

Instantly share code, notes, and snippets.

@jonkiddy
Last active February 11, 2017 15:25
Show Gist options
  • Save jonkiddy/64391ffd85b3c1f8ba45ce72141c79da to your computer and use it in GitHub Desktop.
Save jonkiddy/64391ffd85b3c1f8ba45ce72141c79da to your computer and use it in GitHub Desktop.
Git Issue Creator
{
"projects_path": "PROJECTS",
"github": {
"username": "YOUR_GITHUB_USERNAME",
"email": "YOUR_EMAIL@gmail.com",
"token": "GITHUB_TOKEN"
}
}
#!/usr/bin/env php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/**
* git-issue is a conveinace function
* Converts a title passed via arguments into the concatonated branch name
* @params args are converted to a single string
* @example git issue 101 Fix bug in database connection
*/
$issue = '';
if (is_numeric($argv[1]) && $argc == 2) {
$user = get_current_user();
$config = json_decode(file_get_contents("/Users/$user/.bin/config.json"));
$username = $config->github->username;
$token = $config->github->token;
$api = 'https://repos.roswellpark.org/api/v3/';
$origin = exec('git config --get remote.origin.url');
$origin = str_replace('.git', '', $origin);
$origin = ltrim($origin, 'git@github.com:');
$origin = str_replace('ps://github.com/', '', $origin);
$curl = 'curl -s -u ' . $username . ':' . $token . ' https://api.github.com/repos/' . $origin . '/issues/' . $argv[1];
$issue = json_decode(shell_exec($curl));
$issue = $argv[1] . '-' . $issue->title;
}
$issue = preg_replace('/[^a-z0-9]+/', '-', trim(strtolower($issue)));
system("git checkout -b $issue");
echo "git checkout -b $issue\n";
exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment