clone_git_file 0.1.5 → 0.1.6
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 +4 -4
- data/README.md +16 -5
- data/Rakefile +4 -7
- data/clone_git_file.gemspec +3 -4
- data/lib/clone_git_file.rb +15 -6
- data/lib/clone_git_file/github_repo_parser.rb +3 -2
- data/lib/clone_git_file/version.rb +1 -1
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13bae9e061bbabf4bfaca08c32fdc35076cda098
|
4
|
+
data.tar.gz: 0b6bddb75912059517b079d27a50e93df2c3e5ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f79061cbdb9b1da10d2027a43ad85a54a0ef25021b58fcf255215c040174403576cab6d6a755c4af66d4c5f43bbb7f6ea706797f7c4187a81f6e072ca81fc37
|
7
|
+
data.tar.gz: 1967c924a6a7a68e4c667f32153462c4bcc9d8d668c8bc1222239d36262150aa221c333e6e37a28a8bbc0a121c96a878327495e01ce62dc6d33a6abf6cc98d98
|
data/README.md
CHANGED
@@ -60,18 +60,29 @@ EDITOR=mvim TARGET_DIRECTORY=~/dev clone_git_file https://github.com/brandoncc/c
|
|
60
60
|
### Bonus
|
61
61
|
|
62
62
|
* You can also supply the repo url or a repo subdirectory url, and that directory will be opened by your editor.
|
63
|
-
* Setup an alias to make using the gem easy. For example, here are mine (zsh):
|
63
|
+
* Setup an alias and/or function to make using the gem easy. For example, here are mine (zsh):
|
64
64
|
|
65
65
|
```bash
|
66
66
|
alias cgf="TARGET_DIRECTORY=~/dev EDITOR=mvim clone_git_file $1"
|
67
|
-
|
67
|
+
|
68
|
+
function ogf () {
|
69
|
+
echo "Cloning, your editor will open when clone has completed..."
|
70
|
+
source <(TARGET_DIRECTORY=~/dev EDITOR=mvim clone_git_file -ts $1)
|
71
|
+
}
|
68
72
|
```
|
69
73
|
|
70
|
-
`cgf` clones, then prints a message with the location of the cloned
|
74
|
+
`cgf` clones, then prints a message with the location of the cloned
|
75
|
+
file/directory.
|
71
76
|
|
72
|
-
`ogf` prints the commands to open the file/directory in my editor. I then
|
77
|
+
`ogf` prints the commands to open the file/directory in my editor. I then
|
78
|
+
use `source <(...)` to pipe the printed command to `source` which runs it
|
79
|
+
in my current shell. This fixes some weird things that happen when opening
|
80
|
+
the editor in a child process, and also allows the current directory of my
|
81
|
+
current shell to be changed (instead of the child process shell which will
|
82
|
+
be lost when you close the editor).
|
73
83
|
|
74
|
-
|
84
|
+
`ogf` has to be a function so that `$1` will expand properly. If you use an
|
85
|
+
alias instead, `$1` doesn't hold the correct value in the nested command.
|
75
86
|
|
76
87
|
# Limitations
|
77
88
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
2
|
+
require "rspec/core/rake_task"
|
3
3
|
|
4
|
-
|
5
|
-
t.libs << "test"
|
6
|
-
t.libs << "lib"
|
7
|
-
t.test_files = FileList['test/**/*_test.rb']
|
8
|
-
end
|
4
|
+
RSpec::Core::RakeTask.new
|
9
5
|
|
10
|
-
task :default => :
|
6
|
+
task :default => :spec
|
7
|
+
task :test => :spec
|
data/clone_git_file.gemspec
CHANGED
@@ -21,14 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
22
|
end
|
23
23
|
|
24
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features)/}) }
|
25
25
|
spec.bindir = "exe"
|
26
26
|
spec.executables = ["clone_git_file"]
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
spec.add_development_dependency "bundler", "~> 1.10"
|
30
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
-
spec.add_development_dependency "
|
32
|
-
spec.add_development_dependency "
|
33
|
-
spec.add_development_dependency "mocha"
|
31
|
+
spec.add_development_dependency "pry"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
34
33
|
end
|
data/lib/clone_git_file.rb
CHANGED
@@ -4,7 +4,7 @@ require "clone_git_file/github_repo_parser"
|
|
4
4
|
module CloneGitFile
|
5
5
|
class Cloner
|
6
6
|
def initialize(file, options = {})
|
7
|
-
@file = file
|
7
|
+
@file = file.gsub("%20", " ")
|
8
8
|
@options = options
|
9
9
|
end
|
10
10
|
|
@@ -35,11 +35,16 @@ module CloneGitFile
|
|
35
35
|
|
36
36
|
def launch_editor
|
37
37
|
commands = ""
|
38
|
-
file_path = "#{local_repo_path}
|
38
|
+
file_path = "#{local_repo_path}"
|
39
|
+
file_path << "/#{parsed_data.file_relative_path}" if parsed_data.file_relative_path
|
39
40
|
|
40
41
|
# change into the directory so that relative file loads will work
|
41
|
-
|
42
|
-
|
42
|
+
if File.directory?(file_path)
|
43
|
+
commands << "cd #{file_path}"
|
44
|
+
else
|
45
|
+
commands << "cd #{File.dirname(file_path)}"
|
46
|
+
end
|
47
|
+
commands << %(\n#{ENV["EDITOR"]} "#{file_path}")
|
43
48
|
|
44
49
|
if @options[:output_run_command_to_terminal]
|
45
50
|
puts(commands)
|
@@ -49,14 +54,18 @@ module CloneGitFile
|
|
49
54
|
end
|
50
55
|
|
51
56
|
def print_clone_location
|
52
|
-
|
57
|
+
clone_path = "#{local_repo_path}"
|
58
|
+
clone_path << "/#{parsed_data.file_relative_path}" if parsed_data.file_relative_path
|
59
|
+
|
60
|
+
puts "Cloned to: #{clone_path}"
|
53
61
|
end
|
54
62
|
|
55
63
|
def clone_repo
|
56
64
|
commands = ""
|
57
65
|
commands << "git clone #{parsed_data.repo_url} #{local_repo_path}"
|
58
66
|
|
59
|
-
|
67
|
+
branch_name = parsed_data.branch_name
|
68
|
+
if branch_name && branch_name != ""
|
60
69
|
commands << "\ncd #{local_repo_path}"
|
61
70
|
commands << "\ngit checkout #{parsed_data.branch_name}"
|
62
71
|
end
|
@@ -36,10 +36,11 @@ module CloneGitFile
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def parse_file_relative_path
|
39
|
-
path = @file.match(%r{#{Regexp.escape(parse_repo_url)}/(.+)$})
|
39
|
+
path = @file.match(%r{#{Regexp.escape(parse_repo_url)}/(.+)$})
|
40
|
+
path = path.nil? ? "" : path[1]
|
40
41
|
path.sub!(%r{^(?:blob|tree)/[^/]+}, '') if has_branch?
|
41
42
|
path.sub!(%r{^/}, '')
|
42
|
-
path
|
43
|
+
path == "" ? nil : path
|
43
44
|
rescue NoMethodError
|
44
45
|
''
|
45
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clone_git_file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Conway
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,33 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: mocha
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
59
|
+
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
61
|
+
version: 3.4.0
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
68
|
+
version: 3.4.0
|
83
69
|
description:
|
84
70
|
email:
|
85
71
|
- brandoncc@gmail.com
|