hgrc_generator 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 204f9bf3a76fd803dbbb93dccd4e8485f7bd3100
4
- data.tar.gz: 9c6ab88a4f6877b6c74dea60dd2c51153a313d2d
3
+ metadata.gz: 684a8ffcd1ac33f3715c64fb0e2157235ff28223
4
+ data.tar.gz: dfb3c70375cf3f5d176a92bceff8620f3eff75ea
5
5
  SHA512:
6
- metadata.gz: 7ca278ea5f831bbf5acabc5946671a3bf228eb2bf0d184775b83cc2269c955da259f52631bb2ee67f580233403f4cbbf7523dcd993a7d85f4f6be25f3211cca8
7
- data.tar.gz: 6bdfad757747fc639493ff91ba00a5172057608f6963e681581f5e14c5c4418ddc660f9ccf07cc648ccde81d305caa708e1f7973213fa740956f7da35acf7081
6
+ metadata.gz: 31410a43c198c096cc6492582da4ff5049bcef8064cced6cbb4e05a1f48f31c9bc69471fa1dee34939b05b6626f699d9703150c9b3784d1076263266ad4c5996
7
+ data.tar.gz: fe906df92dc40f069d28ce0e0fd705e1df3c560eaeebb994d01105b4e0981d0fd15cb84eefd1cb3aa2e4d1b09f425ca7653303842614c5d0a3926243efa63318
checksums.yaml.gz.sig CHANGED
Binary file
@@ -49,17 +49,17 @@ module HgrcGenerator
49
49
  end
50
50
 
51
51
  def unix_local_out
52
- commands = Path.get_local_out.reverse
52
+ commands = Path.get_local_out
53
53
  unix_format_for :llo, commands, :out
54
54
  end
55
55
 
56
56
  def unix_local_pull
57
- commands = Path.get_local_in
57
+ commands = Path.get_local_pull
58
58
  unix_format_for :lll, commands, :pull
59
59
  end
60
60
 
61
61
  def unix_local_push
62
- commands = Path.get_local_out.reverse
62
+ commands = Path.get_local_push
63
63
  unix_format_for :llh, commands, :push
64
64
  end
65
65
 
@@ -69,17 +69,17 @@ module HgrcGenerator
69
69
  end
70
70
 
71
71
  def unix_remote_out
72
- commands = Path.get_remote_out.reverse
72
+ commands = Path.get_remote_out
73
73
  unix_format_for :rlo, commands, :out
74
74
  end
75
75
 
76
76
  def unix_remote_pull
77
- commands = Path.get_remote_in
77
+ commands = Path.get_remote_pull
78
78
  unix_format_for :rll, commands, :pull
79
79
  end
80
80
 
81
81
  def unix_remote_push
82
- commands = Path.get_remote_out.reverse
82
+ commands = Path.get_remote_push
83
83
  unix_format_for :rlh, commands, :push
84
84
  end
85
85
 
@@ -1,6 +1,10 @@
1
1
  module HgrcGenerator
2
2
  class Params
3
- attr_reader :include_prefix, :branches, :dry_run, :help
3
+ attr_reader :include_prefix, :in_branches, :out_branches, :dry_run, :help
4
+
5
+ OUT_BRANCHES = [
6
+ :git,
7
+ ]
4
8
 
5
9
  HELP = <<-DOC
6
10
  hgrc_generator version #{HgrcGenerator::VERSION}
@@ -14,6 +18,10 @@ module HgrcGenerator
14
18
  BRANCH_LIST is a list of branches to push to when pushes are not forced.
15
19
  The default branch is automatically included in this list.
16
20
 
21
+ If git is a listed branch, it will not be used in the 'incoming' repos.
22
+ It will be included in the remote outgoing dev repos
23
+ (repos that are remote and force pushed) and pulled in from them, as well.
24
+
17
25
  parameters:
18
26
  --help, -h Show this message.
19
27
  --include_prefix Include the folder one level up from the project folder
@@ -28,24 +36,40 @@ module HgrcGenerator
28
36
  end
29
37
 
30
38
  def initialize(params)
31
- @branches = [:default]
39
+ puts '-' * 80
40
+ @in_branches = [:default]
41
+ @out_branches = []
32
42
  @include_prefix = true
33
43
 
34
44
  params.each do |param|
35
45
  if param.match(/^-/)
36
- case param.downcase
37
- when '--no-prefix' then @include_prefix = false
38
- when '--dry-run', '-n' then @dry_run = true
39
- when '--help', '-h'
40
- puts HELP.gsub(/^ {6}/, '')
41
- exit
42
- end
46
+ set_switches_for param
43
47
  else
44
- @branches << param
48
+ add_branch param
45
49
  end
46
50
  end
47
51
 
48
52
  self.class.params = self
49
53
  end
54
+
55
+ private
56
+
57
+ def set_switches_for(param)
58
+ case param.downcase
59
+ when '--no-prefix' then @include_prefix = false
60
+ when '--dry-run', '-n' then @dry_run = true
61
+ when '--help', '-h'
62
+ puts HELP.gsub(/^ {6}/, '')
63
+ exit
64
+ end
65
+ end
66
+
67
+ def add_branch(branch_name)
68
+ if OUT_BRANCHES.include?(branch_name.downcase.to_sym)
69
+ @out_branches << branch_name
70
+ else
71
+ @in_branches << branch_name
72
+ end
73
+ end
50
74
  end
51
75
  end
@@ -36,19 +36,35 @@ module HgrcGenerator
36
36
  end
37
37
 
38
38
  def get_local_in
39
- paths.select(&:in).select(&:local)
39
+ paths.select(&:local?).select(&:in)
40
40
  end
41
41
 
42
42
  def get_local_out
43
- paths.select(&:out).select(&:local)
43
+ paths.select(&:local?).select(&:out).reverse
44
+ end
45
+
46
+ def get_local_pull
47
+ paths.select(&:local?).select(&:pull)
48
+ end
49
+
50
+ def get_local_push
51
+ paths.select(&:local?).select(&:push).reverse
44
52
  end
45
53
 
46
54
  def get_remote_in
47
- paths.select(&:in).reject(&:local)
55
+ paths.reject(&:local?).select(&:in)
48
56
  end
49
57
 
50
58
  def get_remote_out
51
- paths.select(&:out).reject(&:local)
59
+ paths.reject(&:local?).select(&:out).reverse
60
+ end
61
+
62
+ def get_remote_pull
63
+ paths.reject(&:local?).select(&:pull)
64
+ end
65
+
66
+ def get_remote_push
67
+ paths.reject(&:local?).select(&:push).reverse
52
68
  end
53
69
  end
54
70
 
@@ -62,34 +78,46 @@ module HgrcGenerator
62
78
  :pull
63
79
 
64
80
  def initialize(key, hash)
81
+ @hash = hash
65
82
  @key = key
66
83
  @path = path_for(hash[:path])
67
84
  @force = hash[:force]
68
- @in = in_command if hash[:in]
85
+ @in = in_command if in_command?
69
86
  @out = out_command if hash[:out]
70
- @pull = pull_command if hash[:in]
87
+ @pull = pull_command if in_command?
71
88
  @push = push_command if hash[:out]
72
89
  end
73
90
 
74
- def local
91
+ def local?
75
92
  !path.match(/^ssh:/)
76
93
  end
77
94
 
78
95
  private
79
96
 
97
+ def in_command?
98
+ @hash[:in] ||
99
+ (!params.out_branches.empty? && !local?)
100
+ end
101
+
80
102
  def in_command
81
- [] << "hg in #{key}"
103
+ command = []
104
+ command << "hg in #{key}"
105
+ command.concat out_branches if force
106
+ command
82
107
  end
83
108
 
84
109
  def out_command
85
110
  command = []
86
111
  command << "hg out #{key}"
87
- command.concat branches unless force
112
+ command.concat in_branches unless force
88
113
  command
89
114
  end
90
115
 
91
116
  def pull_command
92
- [] << "hg pull #{key}"
117
+ command = []
118
+ command << "hg pull #{key}"
119
+ command.concat out_branches if force
120
+ command
93
121
  end
94
122
 
95
123
  def push_command
@@ -98,14 +126,23 @@ module HgrcGenerator
98
126
  if force
99
127
  command << '--force'
100
128
  else
101
- command.concat branches
129
+ command.concat in_branches
102
130
  command << '--new-branch'
103
131
  end
104
132
  command
105
133
  end
106
134
 
107
- def branches
108
- params.branches.map do |branch|
135
+ def in_branches
136
+ branches_for :in
137
+ end
138
+
139
+ def out_branches
140
+ branches_for :out
141
+ end
142
+
143
+ def branches_for(direction)
144
+ method = "#{direction}_branches"
145
+ params.send(method).map do |branch|
109
146
  "--branch #{branch}"
110
147
  end
111
148
  end
@@ -1,3 +1,3 @@
1
1
  module HgrcGenerator
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hgrc_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Herrick
metadata.gz.sig CHANGED
Binary file