lazy_fork 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a286c3b1c88148a44039dc4835764dc93a0abb03
4
- data.tar.gz: 767054827dcb0d458bdb7ee9f9151397209089eb
3
+ metadata.gz: 5934cf12a623be2b0ef8b024d836020549027818
4
+ data.tar.gz: 89b873a8f2c4fdff9e90df3daef9b342cfd31c0a
5
5
  SHA512:
6
- metadata.gz: 44c31400dbc4d995a8a46908647dc522ad12c82ca45341e9ec82acc70d98230ec2700d2da0008957f6c5ded8d00d36de6a13aef88837ba359992a73f1c4f90ba
7
- data.tar.gz: 5b8aeeda9578b061f115a3001e03ae02214c3e6db39402ec1b74672c55681d3550b6c4c4b2e3bf13237142c0296888c128f08abe0e7d1ebf449a75d111bbab1b
6
+ metadata.gz: 72baa5e093e5ce2f4e9b6d3e0646aa7d7c5d02214d19b06b06dbac8a0294114f46ba0b1b869d05b876b2ca1ff4b691f48d29d7b005d1417a25f2f2da95495404
7
+ data.tar.gz: 1a13b67b0432a9333d1713dfe8b076899b62c3c0e7a58bd4f3fd43edeef281ac8187b5f4cc82491de4cfb21c50c1c7c1fd8f57bfb8dee7125f094d6b21a6b297
data/README.md CHANGED
@@ -10,11 +10,11 @@ Fork and clone your fork all without leaving the comfort of your terminal. :reli
10
10
 
11
11
  ## Usage
12
12
 
13
- $ lazy_fork --repo <owner>/<repo>
13
+ $ git fork <owner>/<repo>
14
14
 
15
15
  For example, if you wanted to fork this repo:
16
16
 
17
- $ lazy_fork --repo CGA1123/lazy_fork
17
+ $ git fork CGA1123/lazy_fork
18
18
 
19
19
  ## Development
20
20
 
data/bin/git-fork ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lazy_fork'
4
+
5
+ LazyFork::LazyForker.new(nil).fork
data/lazy_fork.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
19
 
20
- spec.executables = ["lazy_fork"]
20
+ spec.executables = ["git-fork"]
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.14"
@@ -1,4 +1,4 @@
1
1
  module LazyFork
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  LAZY_FORK_HOME = File.expand_path("~/.lazy_fork")
4
4
  end
data/lib/lazy_fork.rb CHANGED
@@ -1,55 +1,62 @@
1
1
  require "lazy_fork/version"
2
-
3
- require "optparse"
4
2
  require "io/console"
3
+ require "octokit"
5
4
 
6
5
  module LazyFork
7
6
  class LazyForker
8
7
  def initialize(options)
9
8
  @options = options
10
- @client = nil
11
9
 
12
- # tell the user their being a lazy fork
13
- puts "You lazy forker... v#{LazyFork::VERSION}"
10
+ # tell the user they're being a lazy fork
11
+ puts "You lazy forker..."
14
12
 
15
- unless Dir.exist? LAZY_FORK_HOME
13
+ unless Dir.exist?(LAZY_FORK_HOME)
16
14
  puts "Creating #{LAZY_FORK_HOME}..."
17
15
  Dir.mkdir LAZY_FORK_HOME
18
16
  end
19
- end
20
17
 
21
- def be_lazy
22
18
  authenticate_client
23
- get_repo(ARGV.first)
24
- fork_repo
25
- clone_repo
19
+ end
20
+
21
+ def fork
22
+ clone_repo(fork_repo(get_repo(ARGV.first)), ARGV.last)
23
+ end
24
+
25
+ def fork?(repo)
26
+ @client.repository(repo)[:fork]
27
+ end
28
+
29
+ def source(repo)
30
+ source_slug = @client.repository(repo)[:source][:full_name]
31
+ Octokit::Repository.new(source_slug)
26
32
  end
27
33
 
28
34
  private
29
35
 
30
- def fork_repo
36
+ def fork_repo(repo)
31
37
  puts "Forking..."
32
- fork_repo = @client.fork(@repo)
33
- @forked_repo = Octokit::Repository.new(fork_repo[:full_name])
38
+ fork_repo = @client.fork(repo)
39
+ Octokit::Repository.new(fork_repo[:full_name])
34
40
  end
35
41
 
36
- def clone_repo
37
- puts "Cloning fork (#{@forked_repo.to_s})..."
38
- `git clone #{@forked_repo.url} #{ARGV[1]}`
42
+ def clone_repo(repo, dest=".")
43
+ `git clone #{repo.url} #{dest}`
39
44
  end
40
45
 
41
46
  def get_repo(repo)
42
47
  begin
43
- @repo = Octokit::Repository.new(repo)
48
+ repo = Octokit::Repository.new(repo)
44
49
  rescue Octokit::InvalidRepository
45
50
  puts "Invalid Repository: use owner/name format!"
46
51
  abort
47
52
  end
48
53
 
49
- unless @client.repository?(@repo)
50
- puts "Repo #{@repo.to_s} could not be found."
54
+ unless @client.repository?(repo)
55
+ puts "Repo #{repo.to_s} could not be found."
51
56
  abort
52
57
  end
58
+
59
+ repo
53
60
  end
54
61
 
55
62
  def authenticate_client
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_fork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Gregg
@@ -70,7 +70,7 @@ description:
70
70
  email:
71
71
  - c_arlt@hotmail.com
72
72
  executables:
73
- - lazy_fork
73
+ - git-fork
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
@@ -82,7 +82,7 @@ files:
82
82
  - README.md
83
83
  - Rakefile
84
84
  - bin/console
85
- - bin/lazy_fork
85
+ - bin/git-fork
86
86
  - bin/setup
87
87
  - lazy_fork.gemspec
88
88
  - lib/lazy_fork.rb
data/bin/lazy_fork DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'lazy_fork'
4
- require 'optparse'
5
- require 'octokit'
6
-
7
- options = {}
8
- op = OptionParser.new
9
- op.parse!
10
-
11
- LazyFork::LazyForker.new(options).be_lazy