autoshell 1.0.0.pre.beta → 1.0.1

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
  SHA1:
3
- metadata.gz: 928a9e9b3812a58ba5dc49d411c8d3aa8e1d8ca2
4
- data.tar.gz: de0ace26b2252873a5c1ee7a211a39a2f31a356a
3
+ metadata.gz: 58f7cc0a022ee148921ad31525211ef83963e842
4
+ data.tar.gz: abc7b801e9b7ecf76cd8750663917bca854fe0ba
5
5
  SHA512:
6
- metadata.gz: b1f0cdea37569f2a28b18de0cb4c4bc67be9efb2e97defdc89c616a18c872aa2c25ddf7e2cb418049e8536d8d700d9b0709556c116c0207fe108f45ba28cc839
7
- data.tar.gz: 3a009f5a35d003af45c22648b25eb5212529ea8eaaadd959212143fb0cdd5ddefa1a1613036dc770673b43a0975ebcf2383f24ae881172651211b79f77e62a86
6
+ metadata.gz: 7d3cc1ae23a9f0fc436d297afb34ef0171a6a632758eeff03fe592f939ab258ef21c90b69ebebc7018da6dcc9ac75a375f78d9d4a53ca1a1e4a005cf96a3c78f
7
+ data.tar.gz: 33257ae7b9a532a50b0ddf199841791540969413f11936cf75a7ae74571a927c9014277c53f8964738cb86596ea1e45f1d267604399088fc4666e520de35b0da
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+
11
+ *.gem
data/README.md CHANGED
@@ -20,7 +20,7 @@ Create a new autoshell object with optional path and environment hash.
20
20
 
21
21
  ```ruby
22
22
  env = { 'FOO' => 'bar' }
23
- sh = Autoshell.new('~/code/autoshell', env)
23
+ sh = Autoshell.new('~/code/autoshell', env: env)
24
24
  sh.clone('https://github.com/ryanmark/autoshell-ruby.git')
25
25
  sh.setup_environment
26
26
  sh.cd |s| { s.run('bundle', 'exec', 'rake', 'test') }
@@ -115,9 +115,15 @@ module Autoshell
115
115
 
116
116
  # Copy this working dir to another path
117
117
  # @param path [String] destination path to copy to
118
- def copy_to(path = nil)
118
+ def copy_to(path = nil, force: nil)
119
119
  return super if path.nil?
120
- cp '.', path
120
+
121
+ unless Dir.exist? working_dir
122
+ raise CommandError,
123
+ "copy_to: The directory '#{working_dir}' does not exist"
124
+ end
125
+
126
+ cp '.', path, force: force
121
127
  self.class.new(expand path)
122
128
  end
123
129
 
@@ -6,10 +6,27 @@ module Autoshell
6
6
  # @return [String] (master) branch of the current repo
7
7
  module Git
8
8
  def branch
9
- @branch ||= git? ? git('rev-parse', '--abbrev-ref', 'HEAD') : 'master'
9
+ @branch ||= 'master'
10
10
  end
11
11
  attr_writer :branch
12
12
 
13
+ # Set the branch from a repo url
14
+ #
15
+ # @param [String] Git repository URL
16
+ # @return [string] Branch name
17
+ def branch_from_repo_url(repo_url)
18
+ if repo_url =~ /#\S+[^\/]/
19
+ @branch = repo_url.split('#')[1]
20
+ else
21
+ @branch = 'master'
22
+ end
23
+ end
24
+
25
+ def commit_hash_for_checkout
26
+ @commit_hash_for_checkout ||= 'HEAD'
27
+ end
28
+ attr_writer :commit_hash_for_checkout
29
+
13
30
  # Has this repo been cloned to disk?
14
31
  #
15
32
  # @return [Boolean] True if this dir is a cloned repo
@@ -22,13 +39,14 @@ module Autoshell
22
39
  # @return [String] Output of git commands
23
40
  def update
24
41
  [
25
- git('checkout', working_dir),
26
- git('clean', '-fd'),
27
- git('checkout', 'master'),
42
+ git('checkout', '.'),
43
+ git('clean', '-ffd'),
44
+ git('checkout', branch),
28
45
  git('pull', '--recurse-submodules=yes'),
29
46
  git('fetch', 'origin'),
30
- git('checkout', branch),
31
- git('submodule', 'update', '--init')
47
+ git('checkout', commit_hash_for_checkout),
48
+ git('submodule', 'update', '--init'),
49
+ git('clean', '-ffd')
32
50
  ].join("\n")
33
51
  end
34
52
 
@@ -47,7 +65,17 @@ module Autoshell
47
65
  # @return [String] Output of git commands
48
66
  def clone(repo_url)
49
67
  mkpdir working_dir
50
- run 'git', 'clone', '--recursive', repo_url, working_dir
68
+ run 'git', 'clone', '--recursive', repo_url.split('#')[0], working_dir
69
+ branch_from_repo_url(repo_url)
70
+ update
71
+ end
72
+
73
+ # Checkout a specific hash on the repo
74
+ #
75
+ # @param [String] Git version hash
76
+ # @return [String] Output of git commands
77
+ def checkout_version(version_hash)
78
+ git 'checkout', version_hash || 'HEAD'
51
79
  end
52
80
 
53
81
  # Get the current commit hash
@@ -1,4 +1,4 @@
1
1
  # Version info
2
2
  module Autoshell
3
- VERSION = '1.0.0-beta'
3
+ VERSION = '1.0.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoshell
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-01 00:00:00.000000000 Z
11
+ date: 2016-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -149,9 +149,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ">"
152
+ - - ">="
153
153
  - !ruby/object:Gem::Version
154
- version: 1.3.1
154
+ version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
157
  rubygems_version: 2.4.5