git-pull-request
Advanced tools
Comparing version 0.3.0 to 0.3.1
49
gpr.js
@@ -11,3 +11,3 @@ #!/usr/local/bin/node | ||
var version = 'git-pull-request 0.3.0'; | ||
var version = 'git-pull-request 0.3.1'; | ||
var usage = '\n gpr [-i | -l | -p | -b [name] | -d | -D | -h | -v ] <pr#>'; | ||
@@ -22,3 +22,4 @@ var help = usage + '\n\n' + | ||
' [-D | Delete] <pr#> Force delete the gpr/<pr#> branch.\n' + | ||
' [-l | ls | list] [-r | remote] List local gpr branches. / List 30 most recent open PRs.\n\n' + | ||
' [-l | ls | list] [-r | remote] List local gpr branches. / List 30 most recent open PRs.\n' + | ||
' [-n] [user:branch] Fetch from the named ref and checkout on a detached HEAD.\n\n' + | ||
' [-v | version] Show git-pull-request version.\n' + | ||
@@ -28,3 +29,3 @@ ' [-h | help] This help.\n\n' + | ||
// Get the repo name from the package.jason in the neareast parent directory | ||
// Get the repo name from the package.jaon in the neareast parent directory | ||
var npmPrefix = execSync('npm prefix', {cwd: process.cwd(), encoding: 'utf8'}).replace(/\s+/g, ''); | ||
@@ -34,4 +35,6 @@ | ||
var packageFile = JSON.parse(fs.readFileSync(npmPrefix + '/package.json', 'utf8')); | ||
var repo = packageFile.repository.url.split('/') | ||
repo = repo[3]+ '/' + repo[4].slice(0, -4) | ||
var repo = packageFile.repository.url.split('/'); | ||
var repoName = repo[4].slice(0, -4); | ||
repo = repo[3]+ '/' + repoName; | ||
var path = '/repos/' + repo + '/pulls'; | ||
@@ -55,3 +58,2 @@ // Read the command-line args | ||
if (args[3] == '-r' || args[3] == 'remote' || args[3] == 'pr' || args[3] == 'pr') { | ||
var path = 'https://api.github.com/repos/callemall/material-ui/pulls' | ||
break; | ||
@@ -64,9 +66,23 @@ } | ||
case 'ls-remote': case 'lsr': case '-r': | ||
var path = 'https://api.github.com/repos/callemall/material-ui/pulls' | ||
break; | ||
case '-n': | ||
if (args.length < 4) { | ||
exit(usage); | ||
}; | ||
ref = args[3].split(':'); | ||
if (ref.length !== 2) { | ||
exit(usage); | ||
}; | ||
execho('git fetch ' + 'https://github.com/' + ref[0] + '/' + repoName + ' \'' + ref[1] + '\''); | ||
execho('git checkout FETCH_HEAD'); | ||
process.exit(); | ||
default: | ||
var prNumber = args[args.length - 1]; | ||
if (~~prNumber === 0) { exit(usage + '\n\n <pr> must be a number.'); }; | ||
var path = '/repos/' + repo + '/pulls/' + prNumber; | ||
var path = path + '/' + prNumber; | ||
}; | ||
@@ -127,4 +143,2 @@ | ||
var remote = response.head.repo.clone_url + ' \'' + response.head.ref + '\''; | ||
var pull = 'git pull ' + remote | ||
var fetch = 'git fetch ' + remote | ||
}; | ||
@@ -142,2 +156,3 @@ | ||
} | ||
// Process args | ||
@@ -160,3 +175,3 @@ switch(args[2]) { | ||
case 'pull': case '-p': | ||
execho(pull); | ||
execho('git pull ' + remote); | ||
break; | ||
@@ -174,7 +189,2 @@ | ||
default: | ||
execho(fetch); | ||
execho('git checkout FETCH_HEAD'); | ||
break; | ||
case 'branch': case '-b': | ||
@@ -187,3 +197,8 @@ if (args.length === 5) { | ||
execho('git checkout -B ' + branch + ' master'); | ||
execho(pull); | ||
execho('pull ' + remote); | ||
break; | ||
default: | ||
execho('git fetch ' + remote); | ||
execho('git checkout FETCH_HEAD'); | ||
} | ||
@@ -190,0 +205,0 @@ }); |
{ | ||
"name": "git-pull-request", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "A cli utility to pull a remote branch based on a github PR number", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,2 +22,3 @@ ## git-pull-request [![npm version](https://badge.fury.io/js/git-pull-request.svg)](https://badge.fury.io/js/git-pull-request) | ||
[-l | ls | list] [-r | remote] List local gpr branches. / List 30 most recent open PRs. | ||
[-n] [user:branch] Fetch from the named ref and checkout on a detached HEAD. | ||
@@ -27,3 +28,3 @@ [-v | version] Show git-pull-request version. | ||
<pr#> PR number to apply the command to. | ||
<pr#> PR number to apply the command to. | ||
``` |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
8906
164
29
2