git-copy 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +1 -0
  3. data/bin/git-copy +5 -34
  4. data/lib/git-copy.rb +38 -0
  5. metadata +18 -3
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2FiN2RhNGUzNzY0MWVkNTM2OTZkYjNmZTdjYjgzMmI4YTlkNmY5ZA==
4
+ NjMzYTdjOWM5ODM3N2RkZTRlZGQ1ZWYwYTcyZTZlYTc2N2QxYzg2NQ==
5
5
  data.tar.gz: !binary |-
6
- ZmY4ZjI1NGRhZWQ3MjI2YzhiOTM2MWVmMzdiYzMwMTllOTQ1YjQ4Yw==
6
+ ZWVjMGEwM2IxMGZlMGUzNTcyYjc1NGQyZjhjNjFmNjBhM2JlMDllMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjQ3MDQ2MjNlMzM2MDU2M2Q2Y2E4MjllZDBjZjg2NDMzNzVhMTI4YmFhYzBm
10
- NTUxODA1NGJiZTBhYjJkMzk3ZmY0M2E0NzEwYjY5OTZmMzg4ZmM3YmMyMTQy
11
- OTM2NzA4MTU2Y2NmMDMzZDA5MDE5ZjhkMWZmZjkxMDNjNmMwNGI=
9
+ Yzk4Y2U4Y2U2N2QxYmVhMDYxZDdmNDViMjc3OTNmOWU5OGQwMzA4ODFiZDEz
10
+ NmM2ZWVhYzFmY2RmMTdhYmU3YWE1MWVkODJhYTRmMGQ0MWJhOWQ3YzNmMWQw
11
+ NmJkNTlhNjUzYmNlNmJkZWFkYTQ3YWQwNmYyNzliMjhlZTI3MTM=
12
12
  data.tar.gz: !binary |-
13
- NGM1Nzk1YmMwYmY3MGQ4ZmI0Y2I5ODFmZjIwYzBmMGU2OTBlMDgxYmI5NDQ5
14
- NDJhYjQyN2E0N2RiMmIwOTJkNzFhZTcxYTI3NjRjYzFhMTUyODg1M2I3ODkz
15
- NzU1NmY2MmMyNjhiYTk2MDY2YThmMjllM2M5NWRmOGQyMTE3NmU=
13
+ YzRlMDg2OWM1ZWY4NGRiMWExNmRmMDcyYjkyMTllNTllZTRjOWMwOGI0ODAz
14
+ Y2ZlY2ZkNTMzNTE2MjRjZmE0YTFjMjllNGFhZWY5MjRmN2UyOWViN2ExMTg0
15
+ Y2FiMDE4MGExMGUyMTVjMmE2ZjBiYTgxOGVmNGY3YzBmNDhhZTI=
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  [![Gem](https://img.shields.io/gem/v/git-copy.svg)](https://rubygems.org/gems/git-copy)
6
6
  [![Build Status](https://travis-ci.org/cybertk/git-copy.svg?branch=master)](https://travis-ci.org/cybertk/git-copy)
7
+ [![Dependency Status](https://gemnasium.com/cybertk/git-copy.svg)](https://gemnasium.com/cybertk/git-copy)
7
8
 
8
9
  ## Getting Started
9
10
 
@@ -1,39 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- #
2
+ # encoding: utf-8
3
3
 
4
- require "optparse"
5
- require "tmpdir"
6
- require "addressable/uri"
7
-
8
- def GitCopy(src, dst)
9
- # Copy a remote git repo to another remote destination
10
- #
11
- # Example:
12
- # >> GitCopy("https://github.com/cybertk/git-copy", "https://bitbucket.com/mirror.git")
13
- # >> GitCopy("https://github.com/cybertk/git-copy", "mirror.git")
14
- uri = Addressable::URI.parse(dst)
15
-
16
- # Convert to absolute path for local path
17
- dst = File.absolute_path(dst) unless uri.scheme
18
-
19
- if uri.scheme or File.exist? dst
4
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
20
5
 
21
- Dir.mktmpdir("git-copy-") do |dir|
22
- # Clone source into temp working dir
23
- `git clone --bare #{src} #{dir}`
24
- return if $? != 0
25
-
26
- Dir.chdir(dir)
27
- `git push -f --mirror #{dst}`
28
- return if $? != 0
29
- end
30
- else
31
- # Copy to local path
32
- `git clone --bare #{src} #{dst}`
33
- return if $? != 0
34
- end
35
-
36
- end
6
+ require "optparse"
7
+ require 'git-copy'
37
8
 
38
9
  options = {}
39
10
  optparse = OptionParser.new do |opts|
@@ -56,4 +27,4 @@ optparse = OptionParser.new do |opts|
56
27
  end
57
28
  end.parse!
58
29
 
59
- GitCopy(ARGV[0], ARGV[1])
30
+ Git.copy(ARGV[0], ARGV[1])
@@ -0,0 +1,38 @@
1
+ require 'tmpdir'
2
+ require 'addressable/uri'
3
+
4
+ module Git
5
+
6
+ def self.copy(src, dst)
7
+ # Copy a remote git repo to another remote destination
8
+ #
9
+ # Example:
10
+ # >> GitCopy("https://github.com/cybertk/git-copy", "https://bitbucket.com/mirror.git")
11
+ # >> GitCopy("https://github.com/cybertk/git-copy", "mirror.git")
12
+ uri = Addressable::URI.parse(dst)
13
+
14
+ # Convert to absolute path for local path
15
+ dst = File.absolute_path(dst) unless uri.scheme
16
+
17
+ if uri.scheme || File.exist?(dst)
18
+
19
+ Dir.mktmpdir('git-copy-') do |dir|
20
+ # Clone source into temp working dir
21
+ unless `git clone --bare #{src} #{dir}`.to_i == 0
22
+ raise 'git clone faild'
23
+ end
24
+
25
+ unless `cd #{dir}; git push -f --mirror #{dst}`.to_i == 0
26
+ raise 'git push faild'
27
+ end
28
+ end
29
+ else
30
+ # Copy to local path
31
+ unless `git clone --bare #{src} #{dst}`.to_i == 0
32
+ raise 'git clone failed'
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-copy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quanlong He
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2015-06-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: addressable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.3'
13
27
  description: Git plugin for copy remote/local git repo to another remote/local destination
14
28
  email: kyan.ql.he@gmail.com
15
29
  executables:
@@ -20,6 +34,7 @@ files:
20
34
  - LICENSE
21
35
  - README.md
22
36
  - bin/git-copy
37
+ - lib/git-copy.rb
23
38
  homepage: https://github.com/cybertk/git-copy
24
39
  licenses:
25
40
  - MIT