git-copy 0.1.0 → 0.2.0

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.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +2 -2
  3. data/bin/git-copy +20 -6
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzQ3MThmNjllNzEzNzdiYjM4OGNlMzY5OWQyNGIxNTEzNWFlMGJmZg==
4
+ N2FiN2RhNGUzNzY0MWVkNTM2OTZkYjNmZTdjYjgzMmI4YTlkNmY5ZA==
5
5
  data.tar.gz: !binary |-
6
- MmQxMDNlMmM4NDEzZmNjMjM1Mjk3OTUzNzdkYzcxNzM2MjNhZjg4MA==
6
+ ZmY4ZjI1NGRhZWQ3MjI2YzhiOTM2MWVmMzdiYzMwMTllOTQ1YjQ4Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTM1NDk5MGYwODdlZGM4NWQ4YWVjNjI5YTRmYTBhNTUxOTlkYTZiNDBmNGRm
10
- YWY1NzkwMGMyZTU5OTRjNWIyMTdlZTZmYmM0NWVjMTk3NmE3NTBkZDlhZGFm
11
- ZWRjNDdhZWM0ZTdmNzYxMjNhOGNjODgyMWJkMmU4ZTc3ZjBiYTQ=
9
+ MjQ3MDQ2MjNlMzM2MDU2M2Q2Y2E4MjllZDBjZjg2NDMzNzVhMTI4YmFhYzBm
10
+ NTUxODA1NGJiZTBhYjJkMzk3ZmY0M2E0NzEwYjY5OTZmMzg4ZmM3YmMyMTQy
11
+ OTM2NzA4MTU2Y2NmMDMzZDA5MDE5ZjhkMWZmZjkxMDNjNmMwNGI=
12
12
  data.tar.gz: !binary |-
13
- YTcxMzViYjBiMTM1NmI4MGQ0NGUwOTY5MWE0YzNjOGI3NGU0MTM4ZWFjMmZh
14
- MjZiNzBlNDg4NzNlODgyNmQyMmE2NTg5YjY1NTJjYmM4NzY1Y2JkNGE5YTcy
15
- NmE4YTUxNDViOTM1OTAyNTI5NzNhMTJkZDAyNTc1ZmNmZDEyOTU=
13
+ NGM1Nzk1YmMwYmY3MGQ4ZmI0Y2I5ODFmZjIwYzBmMGU2OTBlMDgxYmI5NDQ5
14
+ NDJhYjQyN2E0N2RiMmIwOTJkNzFhZTcxYTI3NjRjYzFhMTUyODg1M2I3ODkz
15
+ NzU1NmY2MmMyNjhiYTk2MDY2YThmMjllM2M5NWRmOGQyMTE3NmU=
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  ## git-copy
2
2
 
3
- > Git plugin for copy remote git repo to another remote destination
3
+ > Git plugin for copy remote/local git repo to another remote/local destination
4
4
 
5
- [![Gem](https://img.shields.io/gem/v/git-copy.svg)]()
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
7
 
8
8
  ## Getting Started
@@ -3,19 +3,33 @@
3
3
 
4
4
  require "optparse"
5
5
  require "tmpdir"
6
+ require "addressable/uri"
6
7
 
7
8
  def GitCopy(src, dst)
8
9
  # Copy a remote git repo to another remote destination
9
10
  #
10
11
  # Example:
12
+ # >> GitCopy("https://github.com/cybertk/git-copy", "https://bitbucket.com/mirror.git")
11
13
  # >> GitCopy("https://github.com/cybertk/git-copy", "mirror.git")
12
- Dir.mktmpdir("git-copy") do |dir|
13
- # Clone source into temp working dir
14
- `git clone --bare #{src} #{dir}`
15
- return if $? != 0
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
20
+
21
+ Dir.mktmpdir("git-copy-") do |dir|
22
+ # Clone source into temp working dir
23
+ `git clone --bare #{src} #{dir}`
24
+ return if $? != 0
16
25
 
17
- Dir.chdir(dir)
18
- `git push -f --mirror #{dst}`
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}`
19
33
  return if $? != 0
20
34
  end
21
35
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-copy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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-03-26 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Git plugin for copy remote git repo to another remote destination
13
+ description: Git plugin for copy remote/local git repo to another remote/local destination
14
14
  email: kyan.ql.he@gmail.com
15
15
  executables:
16
16
  - git-copy
@@ -43,5 +43,5 @@ rubyforge_project:
43
43
  rubygems_version: 2.4.5
44
44
  signing_key:
45
45
  specification_version: 4
46
- summary: Copy remote git repo to another remote destination
46
+ summary: Copy git repo to another destination
47
47
  test_files: []