daun 0.1.3 → 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.
- checksums.yaml +8 -8
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +6 -1
- data/daun.gemspec +1 -0
- data/lib/daun/cli.rb +26 -1
- data/lib/daun/rugged_daun.rb +14 -4
- data/lib/daun/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmJiYjI5NDc0OTg5MzE0MjI0YWI2ZDBjYzc4OWE2NjYyMDVkZDA4ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGIxYjZlNWMyYzRjMjg3ZTgwMDEyNWE1Yjg3NTU2MTk0M2YxZDdkMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGM5NGRmY2MzMDgxN2QwYzVlNTk4ZmJjOTE4N2JiNzNkMTRiOTcwNmJmYzA2
|
10
|
+
NDU1YmQzODg2Mjc2Yjg5YzBiYzE0ODRiNzBiM2FkZjQ1NTJlNDI2MWY4ZjJh
|
11
|
+
ODNlZjNkYTJhMTI0NDYxODliYjRiODliODY4OGYwOGJhNGRlZGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWY1NTQyYmUzOWVkMGJiOTQ2ZGRhNTA5YTY4NGE1NTYzOTUwMjllZDYzY2Qx
|
14
|
+
ZWU3ZTg1NDBhY2FjNTg5Yzc2N2RlYjMzMzczNGVlNjk2MWM2N2Y3MDQ2Yzcz
|
15
|
+
MDY4NGY0NGM4ZTgxNmU5ZjQ3ZGQyNTYzNWY2Yzc0NDgxMTY3NTM=
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
LineLength:
|
2
2
|
Max: 120
|
3
3
|
|
4
|
-
# Adopted from https://github.com/codeclimate/codeclimate/
|
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
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
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
|
data/daun.gemspec
CHANGED
data/lib/daun/cli.rb
CHANGED
@@ -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])
|
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
|
data/lib/daun/rugged_daun.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/daun/version.rb
CHANGED
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.
|
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-
|
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.
|