git_pr 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/git_pr/github.rb +16 -4
- data/lib/git_pr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b845e6d7a05d53f4bc31e91986cd886b56c88cd1
|
4
|
+
data.tar.gz: 157e6084f4c39dee37322508e0464cf371f07bc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 103b7d80a8719dde69faba086dd9b959d76c08458f083059c8c52ff7ccac99623eb540c9228c8d511f8ddce51f0a9613e38c3780b414882ec847024319343a65
|
7
|
+
data.tar.gz: f992d1c24326943f34d7568ede54c0fd094337c70ac11a88ccda9263bd230c8e6f1b5b90ed41562f9900a0e544e93190c032b6f9e2a118c8af868c184ea650cc
|
data/lib/git_pr/github.rb
CHANGED
@@ -7,6 +7,7 @@ module GitPr
|
|
7
7
|
|
8
8
|
AUTH_KEY_NAME = "git-merge-pull"
|
9
9
|
NETRC_KEY = "#{AUTH_KEY_NAME}.api.github.com"
|
10
|
+
DEFAULT_REMOTE_KEY = "pr.defaultremote"
|
10
11
|
|
11
12
|
def self.test_credentials
|
12
13
|
n = Netrc.read
|
@@ -81,12 +82,17 @@ module GitPr
|
|
81
82
|
def self.determine_project_name_from_command_line git, project_name, default_remotes
|
82
83
|
# Figure out what GitHub project we're dealing with. First, did they pass us a name of
|
83
84
|
# an existing remote, or did they pass a GitHub project?
|
84
|
-
default_remote_from_gitconfig = git.config
|
85
|
+
default_remote_from_gitconfig = git.config DEFAULT_REMOTE_KEY
|
85
86
|
if project_name
|
86
87
|
project_remote = git.remotes.find { |x| x.name == project_name }
|
87
|
-
elsif default_remote_from_gitconfig
|
88
|
-
puts "Using
|
88
|
+
elsif !default_remote_from_gitconfig.empty?
|
89
|
+
puts "Using #{DEFAULT_REMOTE_KEY} setting '#{default_remote_from_gitconfig}' from gitconfig" if $verbose
|
89
90
|
project_remote = git.remotes.find { |x| x.name == default_remote_from_gitconfig }
|
91
|
+
unless project_remote
|
92
|
+
puts "The remote '#{default_remote_from_gitconfig}' doesn't exist.".red
|
93
|
+
puts "Fix the value of '#{DEFAULT_REMOTE_KEY}' in gitconfig.".red
|
94
|
+
exit -1
|
95
|
+
end
|
90
96
|
else
|
91
97
|
project_remote = git.remotes.find { |x| default_remotes.include? x.name }
|
92
98
|
end
|
@@ -101,10 +107,16 @@ module GitPr
|
|
101
107
|
github_project = project_name
|
102
108
|
end
|
103
109
|
|
110
|
+
unless github_project
|
111
|
+
puts "Unable to determine the active GitHub project.".red
|
112
|
+
puts "For more help, run: git pr -h"
|
113
|
+
exit -1
|
114
|
+
end
|
115
|
+
|
104
116
|
begin
|
105
117
|
github_repo = Octokit.repo "#{github_project}"
|
106
118
|
rescue
|
107
|
-
puts "Project
|
119
|
+
puts "Project '#{github_project}' is not a valid GitHub project.".red
|
108
120
|
exit -1
|
109
121
|
end
|
110
122
|
|
data/lib/git_pr/version.rb
CHANGED