gem-clone 0.3.1 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65f01c6935db365ac746c5c4e6a3bc5b927664f221601f003080d26d2a1fa476
4
- data.tar.gz: 67ceb76ea713a3e3adeb1035da5effbe7173c6780dd6fe5d2f3893ed5128fceb
3
+ metadata.gz: 2f12bc26161d323018bdf18116360bb9b81981044ed51c1d451a4db2cc103b32
4
+ data.tar.gz: 0aea0c5003456030440a5b0a74982cb13813731594a35933a19f9a68d13c2c33
5
5
  SHA512:
6
- metadata.gz: 3740f3e3e5756c62307e6b62718f9c55981ecfc65c32e9db1aac5faa563643251ff5d4ab0c3f9ddaa8ba5d3ff603edf6e9c6be3303558583e310bc1d7e5e8f25
7
- data.tar.gz: b57afb1728d4b3d08bfee562d7bea047e5f7055c246c2c3e18c8403d9e9ba84f640d803a3b2d9f172f067e18d8f06234387a4b97448e4fc8ac4c6e181ce5976d
6
+ metadata.gz: 537472ed15d28e45ef000fa04e2679a6f84ed5ce10df8c66f5ca6353a68bf172c289d5ec3b60033e640592e1029a73e90201771e4b749a7efb81905ad2edbc08
7
+ data.tar.gz: 92aef3618b93a10f46845f101b905bea041d8b6ee4628a710747a455c2f12ae264edbecc756cb89d93b368719aaaeb93b6ae4a638b375cc1285690b862442adc
data/README.md CHANGED
@@ -17,7 +17,9 @@ gem install rubygems-clone-0.1.0.gem
17
17
 
18
18
  ## Prerequisites
19
19
 
20
- This plugin requires `ghq` to be installed and available in your PATH.
20
+ This plugin works best with `ghq` but will automatically fall back to `git clone` if `ghq` is not available.
21
+
22
+ ### Recommended: Install ghq
21
23
 
22
24
  ```bash
23
25
  # Install ghq (example for macOS)
@@ -27,6 +29,10 @@ brew install ghq
27
29
  go install github.com/x-motemen/ghq@latest
28
30
  ```
29
31
 
32
+ ### Fallback: Git only
33
+
34
+ If `ghq` is not installed, the plugin will automatically use `git clone` instead. Make sure `git` is available in your PATH.
35
+
30
36
  ## Usage
31
37
 
32
38
  ```bash
@@ -47,7 +53,10 @@ The command will:
47
53
  - `source_code_uri` metadata
48
54
  - `homepage_uri` (if it looks like a repository URL)
49
55
  - `project_uri` (if it looks like a repository URL)
50
- 3. Use `ghq get` to clone the repository (unless `--show-url` is specified)
56
+ 3. Clone the repository using:
57
+ - `ghq get` (preferred method if available)
58
+ - `git clone` (fallback if ghq is not available)
59
+ - Skip cloning if `--show-url` is specified
51
60
 
52
61
  ## Options
53
62
 
@@ -57,16 +66,27 @@ The command will:
57
66
  ## Examples
58
67
 
59
68
  ```bash
69
+ # With ghq available
60
70
  $ gem clone sinatra
61
71
  Executing: ghq get https://github.com/sinatra/sinatra
62
72
  Successfully cloned repository: https://github.com/sinatra/sinatra
63
73
 
74
+ # With verbose output
64
75
  $ gem clone rails --verbose
65
76
  Fetching gem metadata for 'rails'...
66
77
  Found repository URL: https://github.com/rails/rails
67
78
  Executing: ghq get https://github.com/rails/rails
68
79
  Successfully cloned repository: https://github.com/rails/rails
69
80
 
81
+ # Fallback to git clone when ghq is not available
82
+ $ gem clone rails --verbose
83
+ Fetching gem metadata for 'rails'...
84
+ Found repository URL: https://github.com/rails/rails
85
+ ghq not found, falling back to git clone
86
+ Executing: git clone https://github.com/rails/rails
87
+ Successfully cloned repository: https://github.com/rails/rails
88
+
89
+ # Show URL only
70
90
  $ gem clone rails --show-url
71
91
  https://github.com/rails/rails
72
92
  ```
@@ -1,5 +1,4 @@
1
1
  require 'rubygems/command'
2
- require 'rubygems/remote_fetcher'
3
2
  require 'json'
4
3
  require 'net/http'
5
4
  require 'uri'
@@ -108,6 +107,23 @@ Examples:
108
107
  end
109
108
 
110
109
  def clone_repository(url)
110
+ if command_available?('ghq')
111
+ clone_with_ghq(url)
112
+ elsif command_available?('git')
113
+ clone_with_git(url)
114
+ else
115
+ alert_error "Neither 'ghq' nor 'git' is available in your PATH. Please install one of them."
116
+ terminate_interaction 1
117
+ end
118
+ end
119
+
120
+ private
121
+
122
+ def command_available?(command)
123
+ system("which #{command} > /dev/null 2>&1")
124
+ end
125
+
126
+ def clone_with_ghq(url)
111
127
  command = "ghq get #{url}"
112
128
  say "Executing: #{command}" if options[:verbose]
113
129
 
@@ -116,7 +132,22 @@ Examples:
116
132
  if $?.success?
117
133
  say "Successfully cloned repository: #{url}"
118
134
  else
119
- alert_error "Failed to clone repository. Make sure 'ghq' is installed and available in your PATH."
135
+ alert_error "Failed to clone repository with ghq."
136
+ terminate_interaction 1
137
+ end
138
+ end
139
+
140
+ def clone_with_git(url)
141
+ command = "git clone #{url}"
142
+ say "ghq not found, falling back to git clone" if options[:verbose]
143
+ say "Executing: #{command}" if options[:verbose]
144
+
145
+ system(command)
146
+
147
+ if $?.success?
148
+ say "Successfully cloned repository: #{url}"
149
+ else
150
+ alert_error "Failed to clone repository with git."
120
151
  terminate_interaction 1
121
152
  end
122
153
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-clone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi SHIBATA