git-helpers 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/exe/git-upstream +19 -0
- data/lib/git/helpers.rb +1 -0
- data/lib/git/helpers/create_upstream.rb +23 -0
- data/lib/git/helpers/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1965e70b75bae8cdb1d147b9d48318d4829b402
|
4
|
+
data.tar.gz: d81ee753607e9ae6fd47ab8c7ae2e5c452a19f79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 837b29a2276bf2fc191eba88d37329f11e119a8860f5e46380632011e27d60765d45c455884c6dbf7b53f85004743507400f990d0ea9e1a418436b85c570f6ae
|
7
|
+
data.tar.gz: d2e2faab51148f98af05c169b025d5b57af5402ff2ead03ed38d9a50f4fa5a5a053659cd83a4de984aed05c80ed0dd83236b6d9dbce70949f8b92cef63ddd0e8
|
data/README.md
CHANGED
@@ -41,6 +41,10 @@ Forms:
|
|
41
41
|
* `git pr target_remote target_branch` - Opens the comparison between `target_remote` at the `target_branch` and origin at the current branch
|
42
42
|
* `git pr target_remote/target_branch source_remote/source_branch` - Opens the comparison between `target_remote` at the `target_branch` and `source_remote` at the `source_branch`
|
43
43
|
|
44
|
+
### Upstream
|
45
|
+
Running `git upstream <USER>` on a repository (that doesn't already have an upstream),
|
46
|
+
will create a read-only `upstream` remote using the existing `origin` remote's URL
|
47
|
+
|
44
48
|
## Development
|
45
49
|
|
46
50
|
After checking out the repo, run `bundle` to install dependencies. Then, run `bundle exec rake spec` to run the tests.
|
data/exe/git-upstream
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'git/helpers'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
OptionParser.new do |opts|
|
6
|
+
opts.banner = "Git-Helpers git upstream\n"\
|
7
|
+
"Creates a read-only upstream remote for the given user\n"\
|
8
|
+
'Usage: git upstream <USER>'
|
9
|
+
opts.on_tail '-h', '--help', 'Shows this help message' do
|
10
|
+
puts opts
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
opts.on_tail '-v', '--version', 'Shows the version of git-helpers' do
|
14
|
+
puts "Git-Helpers version #{Git::Helpers::VERSION}"
|
15
|
+
exit 0
|
16
|
+
end
|
17
|
+
end.parse!
|
18
|
+
|
19
|
+
Git::Helpers.create_upstream ARGV.shift
|
data/lib/git/helpers.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'git/helpers/utils'
|
2
|
+
|
3
|
+
module Git
|
4
|
+
# Provides a set of helper functions to make Git life easier
|
5
|
+
module Helpers
|
6
|
+
require 'git'
|
7
|
+
# Updates a repositories current branch from upstream, and pushes those
|
8
|
+
# to origin
|
9
|
+
# @param upstream_user [String] The user of the upstream repo
|
10
|
+
# @param repo_dir [String] The directory of the repo to update
|
11
|
+
# @param print_details [Boolean] Print messages for each action or not
|
12
|
+
def self.create_upstream(upstream_user, repo_dir = Dir.pwd, print_details = true)
|
13
|
+
repo = Git.open(repo_dir)
|
14
|
+
puts "Upstream already exists" if print_details && !Utils.remote?(repo, 'upstream')
|
15
|
+
remote = Utils.remotes_hash(repo)['origin']
|
16
|
+
user = Utils.true_name(remote)
|
17
|
+
url = Utils.transform_url(remote.url, 'git')
|
18
|
+
url.sub!(user, upstream_user)
|
19
|
+
puts "Adding upstream with URL #{url}" if print_details
|
20
|
+
repo.add_remote('upstream', url)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/git/helpers/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kierran McPherson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: launchy
|
@@ -159,6 +159,7 @@ executables:
|
|
159
159
|
- git-browse
|
160
160
|
- git-pr
|
161
161
|
- git-update
|
162
|
+
- git-upstream
|
162
163
|
extensions: []
|
163
164
|
extra_rdoc_files: []
|
164
165
|
files:
|
@@ -173,9 +174,11 @@ files:
|
|
173
174
|
- exe/git-browse
|
174
175
|
- exe/git-pr
|
175
176
|
- exe/git-update
|
177
|
+
- exe/git-upstream
|
176
178
|
- git-helpers.gemspec
|
177
179
|
- lib/git/helpers.rb
|
178
180
|
- lib/git/helpers/browse.rb
|
181
|
+
- lib/git/helpers/create_upstream.rb
|
179
182
|
- lib/git/helpers/pull_request.rb
|
180
183
|
- lib/git/helpers/update.rb
|
181
184
|
- lib/git/helpers/utils.rb
|