qb 0.1.37 → 0.1.38

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: cafbcb81c0a8179b326824b5b89203534604398c
4
- data.tar.gz: 46823f3b27926e4c5652f4fac6b2932d3d74250a
3
+ metadata.gz: b3db6c782539a18c0595a06811de825a145c6554
4
+ data.tar.gz: 9b0f932cbf62a32649e8742fd7e1d273fbda591e
5
5
  SHA512:
6
- metadata.gz: b6d08dab932b56a417c31fd56dd3584d8cf6874f6f467dcd22e575806fe39e8894fa447905f18258023be19a0f2c0b17389d1bdb941397058b63f567180fdb8c
7
- data.tar.gz: 3167ccdd9f411767e2302c58adf8d697e428c7515d5c30502e645fe4c43a2d707d34e99fe2c77850c45e77b0607f33dff6bde49744de9ea855ecc48cea16daa0
6
+ metadata.gz: 005c10da52d51cf20e1624d59622471944f3358b5f3f747e2e471ce4f598c90ee3aba9f2039e0997aca4857b3273c311759f9676f71493127ea3e2754562cde4
7
+ data.tar.gz: e4c764c6a9cbed12327362e497c608174f2e6c28e88b5ccb52054214c7b18813564b4fb6a1800e709c9205ea5cb976312ca49ecf7fc5e5152c01e7c1f13842e1
@@ -73,12 +73,12 @@ module QB::Util::STDIO
73
73
  #
74
74
  debug "closing..."
75
75
 
76
- @thread.kill
77
- @socket.close
76
+ @thread.kill unless @thread.nil?
77
+ @socket.close unless @socket.nil?
78
78
  @socket = nil
79
- @server.close
79
+ @server.close unless @server.nil?
80
80
  @server = nil
81
- FileUtils.rm @path
81
+ FileUtils.rm(@path) if @path.exist?
82
82
 
83
83
  debug "closed."
84
84
  end
@@ -1,7 +1,7 @@
1
1
  module QB
2
2
  GEM_NAME = 'qb'
3
3
 
4
- VERSION = "0.1.37"
4
+ VERSION = "0.1.38"
5
5
 
6
6
  def self.gemspec
7
7
  Gem.loaded_specs[GEM_NAME]
@@ -17,6 +17,8 @@ require 'qb'
17
17
  require 'cmds'
18
18
  require 'nrser'
19
19
 
20
+ using NRSER
21
+
20
22
  class GitSubmoduleUpdate < QB::AnsibleModule
21
23
  def main_dir
22
24
  File.realpath @args['dir']
@@ -44,7 +46,7 @@ class GitSubmoduleUpdate < QB::AnsibleModule
44
46
  detached: detached?(dir),
45
47
  dirty: dirty?(dir),
46
48
  }
47
- }
49
+ }.tap {|subs| QB.debug submodules: subs}
48
50
  end
49
51
 
50
52
  def dirty? repo_dir
@@ -83,6 +85,8 @@ class GitSubmoduleUpdate < QB::AnsibleModule
83
85
  end
84
86
 
85
87
  def attach! submodule
88
+ QB.debug "attaching submodule #{ submodule[:rel_dir] }..."
89
+
86
90
  branch_heads = branch_heads_for_commit submodule
87
91
  branch_head = nil
88
92
 
@@ -95,62 +99,88 @@ class GitSubmoduleUpdate < QB::AnsibleModule
95
99
  # automatically update it because that might break shit.
96
100
  #
97
101
  # do nothing
102
+ puts <<-END.squish
103
+ submodule #{ submodule[:rel_dir] } points to commit
104
+ #{ submodule[:commit] } that is not the head of any branch.
105
+ END
106
+
98
107
  return false
108
+
99
109
  when 1
100
- # commit is head of only one branch
110
+ QB.debug "commit is head of only one branch: #{ branch_heads[0][:ref] }"
101
111
  branch_head = branch_heads[0]
112
+
102
113
  else
103
- # commit is head of multiple branches
114
+ QB.debug "commit is head of multiple branches..."
115
+
104
116
  local = branch_heads.select {|bh| bh[:ref].start_with? 'refs/heads'}
105
117
 
106
118
  case local.length
107
119
  when 0
108
- # commit is head of multiple remote branches
120
+ QB.debug "commit is head of multiple remote branches..."
121
+
109
122
  # see if one is master
110
123
  branch_head = branch_heads.find {|bh| bh[:ref].end_with? 'master'}
111
124
 
112
125
  # if none do we're hosed - not sure which one it should be on
113
126
  if branch_head.nil?
114
- raise NRSER.squish <<-END
127
+ puts <<-END.squish
115
128
  submodule #{ submodule[:rel_dir] } points to commit
116
129
  #{ submodule[:commit] } that heads multiple non-master remote
117
130
  branches: #{ branch_heads.map {|bh| bh[:ref]} }
118
131
  END
132
+
133
+ return false
119
134
  end
120
135
 
136
+ QB.debug "commit is head of local master, using that."
137
+
121
138
  when 1
122
- # the commit is head of one local branch, use it
139
+ QB.debug "the commit is head of one local branch, using it."
140
+
123
141
  branch_head = local[0]
124
142
 
125
143
  else
126
- # the commit heads multiple local branches
144
+ QB.debug "the commit heads multiple local branches..."
145
+
127
146
  # again, see if one is master
128
147
  branch_head = local.find {|b| b[:ref].end_with? 'master'}
129
148
 
130
149
  # if none do we're hosed - not sure which one it should be on
131
150
  if branch_head.nil?
132
- raise NRSER.squish <<-END
151
+ puts <<-END.squish
133
152
  submodule #{ submodule[:rel_dir] } points to commit
134
153
  #{ submodule[:commit] } that heads multiple non-master local
135
154
  branches: #{ local.map {|bh| bh[:ref]} }
136
155
  END
156
+
157
+ return false
137
158
  end
138
- end # case
139
- end
159
+
160
+ QB.debug "commit is head of remote master, using that."
161
+ end # case local.length
162
+ end # case branch_heads.length
163
+
164
+ QB.debug "attaching #{ submodule[:rel_dir] } to #{ branch_head[:ref] }..."
140
165
 
141
166
  branch = branch_head[:ref].split('/')[-1]
142
167
 
143
168
  Dir.chdir submodule[:dir] do
144
- # checkout the branch
169
+ QB.debug "checking out branch #{ branch } for #{ submodule[:rel_dir] }..."
170
+
145
171
  Cmds! "git checkout <%= branch %>", branch: branch
146
172
 
147
173
  # do a pull if the head was on the remote
148
174
  if branch_head[:ref].start_with? 'refs/remotes'
175
+ QB.debug "commit is head of remote branch, pulling..."
176
+
149
177
  Cmds! "git pull origin <%= branch %>", branch: branch
150
178
  end
151
179
  end
152
180
 
181
+ QB.debug "attached."
153
182
  @changed = true
183
+ true
154
184
  end
155
185
 
156
186
  def main
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.37
4
+ version: 0.1.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser