daun 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTIzNWE5NDBmNTFhM2Q0NzI1ZWUyYWVmYzFkOWU5NjA0ZGI5NzUwMg==
4
+ ZmJiYjI5NDc0OTg5MzE0MjI0YWI2ZDBjYzc4OWE2NjYyMDVkZDA4ZA==
5
5
  data.tar.gz: !binary |-
6
- MDU2YTkwM2ViNjY4YTc1MGM1ZjQwYTM3ZWU0MmJkZTYzMWJkOTljYw==
6
+ NGIxYjZlNWMyYzRjMjg3ZTgwMDEyNWE1Yjg3NTU2MTk0M2YxZDdkMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDhlODUwNjkxZjkzZjJjM2MzMDQ2YjE2NTAwODMwMzYyMGIyMmM1YTllMDY4
10
- MGY2N2VlYTg4ODY3MmE4OTIzOGNmMGY4OWM4OTI5MTIyYjUxZjYyOWM0ODZl
11
- NDVkYTEzYjRmNTBkMzdhNDdlYjFhNDVjYzAwY2MwYTBmMDkxODU=
9
+ ZGM5NGRmY2MzMDgxN2QwYzVlNTk4ZmJjOTE4N2JiNzNkMTRiOTcwNmJmYzA2
10
+ NDU1YmQzODg2Mjc2Yjg5YzBiYzE0ODRiNzBiM2FkZjQ1NTJlNDI2MWY4ZjJh
11
+ ODNlZjNkYTJhMTI0NDYxODliYjRiODliODY4OGYwOGJhNGRlZGI=
12
12
  data.tar.gz: !binary |-
13
- MTJlNTY1M2I4ODMzMzFiNDc1NTBhOWE2NTAwZGEwZTk1M2JlMzU3ZDNiY2Fh
14
- ZjBlYzYyNzYyOTAwYWZkMGY1ODA3NTU1NTlhMDQ2Yjg3Nzc0ZDYxZTQ4YTNk
15
- NTE0NjlhYWMzM2JiMzAxMDJkYjI2N2M1MzkyZGRiNWE5N2M4Nzg=
13
+ YWY1NTQyYmUzOWVkMGJiOTQ2ZGRhNTA5YTY4NGE1NTYzOTUwMjllZDYzY2Qx
14
+ ZWU3ZTg1NDBhY2FjNTg5Yzc2N2RlYjMzMzczNGVlNjk2MWM2N2Y3MDQ2Yzcz
15
+ MDY4NGY0NGM4ZTgxNmU5ZjQ3ZGQyNTYzNWY2Yzc0NDgxMTY3NTM=
@@ -1,7 +1,7 @@
1
1
  LineLength:
2
2
  Max: 120
3
3
 
4
- # Adopted from https://github.com/codeclimate/codeclimate/blame/master/config/rubocop/.rubocop.yml
4
+ # Adopted from https://github.com/codeclimate/codeclimate/blob/master/config/rubocop/.rubocop.yml
5
5
  Metrics/MethodLength:
6
6
  Max: 30
7
7
 
@@ -17,4 +17,7 @@ Metrics/ClassLength:
17
17
 
18
18
  # Conflicts with IntelliJ auto formatting
19
19
  Style/MultilineMethodCallIndentation:
20
+ Enabled: false
21
+
22
+ Style/CaseIndentation:
20
23
  Enabled: false
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.0] - 2016-11-20
6
+ ### Fixed
7
+ \#4 Support fetching SSH URL
8
+
5
9
  ## [0.1.3] - 2016-10-26
6
10
  ### Fixed
7
11
  \#3 Unable to checkout after setting daun.tag.limit
@@ -14,6 +18,7 @@
14
18
  ### Added
15
19
  - Initial release.
16
20
 
17
- [Unreleased]: https://github.com/ceilfors/daun/compare/v0.1.3...HEAD
21
+ [Unreleased]: https://github.com/ceilfors/daun/compare/v0.2.0...HEAD
22
+ [Unreleased]: https://github.com/ceilfors/daun/compare/v0.1.3...v0.2.0
18
23
  [0.1.2]: https://github.com/ceilfors/daun/compare/v0.1.0...v0.1.2
19
24
  [0.1.3]: https://github.com/ceilfors/daun/compare/v0.1.2...v0.1.3
@@ -39,4 +39,5 @@ Gem::Specification.new do |spec|
39
39
  spec.add_runtime_dependency 'thor', '~> 0.19', '>= 0.19.1'
40
40
  spec.add_runtime_dependency 'logging', '~> 2.0'
41
41
  spec.add_runtime_dependency 'rugged', '~> 0.21'
42
+ spec.add_runtime_dependency 'git_clone_url', '~> 2.0'
42
43
  end
@@ -1,5 +1,7 @@
1
1
  require 'thor'
2
2
  require 'daun'
3
+ require 'uri'
4
+ require 'git_clone_url'
3
5
 
4
6
  module Daun
5
7
  # All daun cli subcommands are made available by this class.
@@ -12,9 +14,32 @@ module Daun
12
14
 
13
15
  desc 'checkout', 'Checks out git working tree as per daun configuration'
14
16
  option :directory, default: '.'
17
+ option :ssh_private_key, default: File.join(ENV['HOME'], '.ssh', 'id_rsa')
18
+ option :ssh_public_key, default: File.join(ENV['HOME'], '.ssh', 'id_rsa.pub')
15
19
 
16
20
  def checkout
17
- Daun::RuggedDaun.new(options[:directory]).checkout
21
+ rugged_daun = Daun::RuggedDaun.new(options[:directory])
22
+ credentials = nil
23
+ begin
24
+ origin_uri = GitCloneUrl.parse(rugged_daun.remote_url)
25
+ credentials =
26
+ case origin_uri
27
+ when URI::SshGit::Generic then
28
+ Rugged::Credentials::SshKey.new(
29
+ username: origin_uri.user,
30
+ privatekey: options[:ssh_private_key],
31
+ publickey: options[:ssh_public_key]
32
+ )
33
+ else
34
+ # Unsupported URI type
35
+ credentials = nil
36
+ end
37
+ rescue URI::InvalidComponentError
38
+ # Potentially a git local protocol which is not supported by GitCloneUrl yet
39
+ credentials = nil
40
+ end
41
+
42
+ rugged_daun.checkout credentials
18
43
  end
19
44
  end
20
45
  end
@@ -28,6 +28,11 @@ module Daun
28
28
  @repository.config
29
29
  end
30
30
 
31
+ # Returns the remote url set to this repository.
32
+ def remote_url
33
+ @repository.remotes['origin'].url
34
+ end
35
+
31
36
  # Checkout git branches and tags in the git repository working directory.
32
37
  #
33
38
  # This method will fetch the latest update from `git remote origin` configured
@@ -35,9 +40,13 @@ module Daun
35
40
  # Once the references are fetch, it will detect if there are new references,
36
41
  # updated references, and deleted references then act upon them
37
42
  # accordingly.
38
- def checkout
43
+ def checkout(credentials = nil)
39
44
  @logger.info 'Fetching git repository..'
40
- refs_diff = fetch_refs
45
+
46
+ fetch_options = {}
47
+ fetch_options[:credentials] = credentials unless credentials.nil?
48
+
49
+ refs_diff = fetch_refs fetch_options
41
50
 
42
51
  refs_diff.added(:remotes).each do |refs|
43
52
  @logger.info "Adding #{refs}.."
@@ -75,13 +84,14 @@ module Daun
75
84
  private
76
85
 
77
86
  # Fetch refs from origin.
78
- def fetch_refs
87
+ def fetch_refs(fetch_options = {})
79
88
  before_fetch = Hash[@repository.refs.collect { |r| [r.name, r.target_id] }]
80
89
 
81
90
  # Prune is not supported by rugged! Deleting all remote refs and re-fetch
82
91
  delete_all_remote_branches
83
92
  delete_all_tags
84
- @repository.remotes['origin'].fetch
93
+
94
+ @repository.remotes['origin'].fetch(nil, fetch_options)
85
95
 
86
96
  delete_all_remote_branches @repository.config['daun.branch.blacklist'].split
87
97
  delete_all_tags @repository.config['daun.tag.blacklist'].split
@@ -1,3 +1,3 @@
1
1
  module Daun
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wisen Tanasa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-21 00:00:00.000000000 Z
11
+ date: 2016-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -228,6 +228,20 @@ dependencies:
228
228
  - - ~>
229
229
  - !ruby/object:Gem::Version
230
230
  version: '0.21'
231
+ - !ruby/object:Gem::Dependency
232
+ name: git_clone_url
233
+ requirement: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ~>
236
+ - !ruby/object:Gem::Version
237
+ version: '2.0'
238
+ type: :runtime
239
+ prerelease: false
240
+ version_requirements: !ruby/object:Gem::Requirement
241
+ requirements:
242
+ - - ~>
243
+ - !ruby/object:Gem::Version
244
+ version: '2.0'
231
245
  description: Daun is a CLI program that will expand git branches and tags to your
232
246
  disk as directories. Daun will keep the expanded directories in sync whenever there
233
247
  are new, updated, or deleted tags and branches.