sugarjar 0.0.8 → 0.0.9
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 +4 -4
- data/README.md +7 -0
- data/lib/sugarjar/commands.rb +63 -22
- data/lib/sugarjar/util.rb +2 -1
- data/lib/sugarjar/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b12b221b467eca9aeba30396d059870a82608120ce1739ded50b4aef55ce7ba
|
4
|
+
data.tar.gz: c84bcab24de60fc61a0241f7c2940d6da6d78bc7416fa3fb92500528a447f9c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e041cd65eb939ea1d2153bf13a8a019e05f194fcf6ce4326c69d62a2de9e34e1d036cf759c5ea17b5b42d8e7e159fc99d65ee75470580a4ed15a854fffc7c87f
|
7
|
+
data.tar.gz: 2c47c2920b6a774ffb83ef16761183ac7dbfcc808a6885335bbeeee5470a29ceff343df4e3748897ab4e8e681e7c7d8b9a5fc3c7ed4d44fafaa40dda6c08b300
|
data/README.md
CHANGED
@@ -191,6 +191,13 @@ $ sj feature dependent-feature test-branch
|
|
191
191
|
Created feature branch dependent-feature based on test-branch
|
192
192
|
```
|
193
193
|
|
194
|
+
## Smartlog
|
195
|
+
|
196
|
+
Smartlog will show you a tree diagram of your branches! Simply run `sj
|
197
|
+
smartlog` or `sj sl` for short.
|
198
|
+
|
199
|
+

|
200
|
+
|
194
201
|
## And more!
|
195
202
|
|
196
203
|
See `sj help` for more commands!
|
data/lib/sugarjar/commands.rb
CHANGED
@@ -165,7 +165,7 @@ class SugarJar
|
|
165
165
|
reponame = File.basename(repo, '.git')
|
166
166
|
dir ||= reponame
|
167
167
|
SugarJar::Log.info("Cloning #{reponame}...")
|
168
|
-
hub('clone', repo, dir, *args)
|
168
|
+
hub('clone', canonicalize_repo(repo), dir, *args)
|
169
169
|
|
170
170
|
Dir.chdir dir do
|
171
171
|
# Now that we have a repo, if we have a hub host set it.
|
@@ -185,7 +185,7 @@ class SugarJar
|
|
185
185
|
# newer 'hub's don't fail and do the right thing...
|
186
186
|
SugarJar::Log.info("Fork (#{@ghuser}/#{reponame}) detected.")
|
187
187
|
hub('remote', 'rename', 'origin', 'upstream')
|
188
|
-
hub('remote', 'add', 'origin',
|
188
|
+
hub('remote', 'add', 'origin', forked_repo(repo, @ghuser))
|
189
189
|
else
|
190
190
|
SugarJar::Log.info("Forked #{reponame} to #{@ghuser}")
|
191
191
|
end
|
@@ -284,24 +284,36 @@ class SugarJar
|
|
284
284
|
s.error?
|
285
285
|
end
|
286
286
|
|
287
|
-
def extract_org(
|
288
|
-
if
|
289
|
-
File.basename(File.dirname(
|
290
|
-
elsif
|
291
|
-
|
287
|
+
def extract_org(repo)
|
288
|
+
if repo.start_with?('http')
|
289
|
+
File.basename(File.dirname(repo))
|
290
|
+
elsif repo.start_with?('git@')
|
291
|
+
repo.split(':')[1].split('/')[0]
|
292
292
|
else
|
293
293
|
# assume they passed in a hub-friendly name
|
294
|
-
|
294
|
+
repo.split('/').first
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
|
-
def
|
299
|
-
repo = if
|
300
|
-
File.basename(
|
298
|
+
def forked_repo(repo, username)
|
299
|
+
repo = if repo.start_with?('http', 'git@')
|
300
|
+
File.basename(repo)
|
301
301
|
else
|
302
|
-
"#{File.basename(
|
302
|
+
"#{File.basename(repo)}.git"
|
303
303
|
end
|
304
|
-
"git@github.com:#{username}/#{repo}"
|
304
|
+
"git@#{@ghhost || 'github.com'}:#{username}/#{repo}"
|
305
|
+
end
|
306
|
+
|
307
|
+
# Hub will default to https, but we should always default to SSH
|
308
|
+
# unless otherwise specified since https will cause prompting.
|
309
|
+
def canonicalize_repo(repo)
|
310
|
+
# if they fully-qualified it, we're good
|
311
|
+
return repo if repo.start_with?('http', 'git@')
|
312
|
+
|
313
|
+
# otherwise, ti's a shortname
|
314
|
+
cr = "git@#{@ghhost || 'github.com'}:#{repo}.git"
|
315
|
+
SugarJar::Log.debug("canonicalized #{repo} to #{cr}")
|
316
|
+
cr
|
305
317
|
end
|
306
318
|
|
307
319
|
def set_hub_host
|
@@ -378,24 +390,53 @@ class SugarJar
|
|
378
390
|
@repo_config[type].each do |check|
|
379
391
|
SugarJar::Log.debug("Running #{type} #{check}")
|
380
392
|
|
381
|
-
|
382
|
-
|
393
|
+
short = check.split.first
|
394
|
+
unless File.exist?(short)
|
395
|
+
SugarJar::Log.error("Configured #{type} #{short} does not exist!")
|
383
396
|
return false
|
384
397
|
end
|
385
398
|
s = Mixlib::ShellOut.new(check).run_command
|
386
|
-
|
399
|
+
|
400
|
+
# Linters auto-correct, lets handle that gracefully
|
401
|
+
if type == 'lint' && dirty?
|
387
402
|
SugarJar::Log.info(
|
388
|
-
"[#{type}] #{
|
403
|
+
"[#{type}] #{short}: #{color('Corrected', :yellow)}",
|
404
|
+
)
|
405
|
+
SugarJar::Log.warn(
|
406
|
+
"The linter modified the repo. Here's the diff:\n",
|
389
407
|
)
|
390
|
-
|
408
|
+
puts hub('diff').stdout
|
409
|
+
loop do
|
410
|
+
$stdout.print(
|
411
|
+
"\nWould you like to\n\t[q]uit and inspect\n\t[a]mend the " +
|
412
|
+
"changes to the current commit and re-run\n > ",
|
413
|
+
)
|
414
|
+
ans = $stdin.gets.strip
|
415
|
+
case ans
|
416
|
+
when /^q/
|
417
|
+
SugarJar::Log.info('Exiting at user request.')
|
418
|
+
exit(1)
|
419
|
+
when /^a/
|
420
|
+
qamend('-a')
|
421
|
+
# break here, if we get out of this loop we 'redo', assuming
|
422
|
+
# the user chose this option
|
423
|
+
break
|
424
|
+
end
|
425
|
+
end
|
426
|
+
redo
|
391
427
|
end
|
392
428
|
|
429
|
+
if s.error?
|
430
|
+
SugarJar::Log.info(
|
431
|
+
"[#{type}] #{short} #{color('failed', :red)}, output follows " +
|
432
|
+
"(see debug for more)\n#{s.stdout}",
|
433
|
+
)
|
434
|
+
SugarJar::Log.debug(s.format_for_exception)
|
435
|
+
return false
|
436
|
+
end
|
393
437
|
SugarJar::Log.info(
|
394
|
-
"[#{type}] #{
|
395
|
-
"(see debug for more)\n#{s.stdout}",
|
438
|
+
"[#{type}] #{short}: #{color('OK', :green)}",
|
396
439
|
)
|
397
|
-
SugarJar::Log.debug(s.format_for_exception)
|
398
|
-
return false
|
399
440
|
end
|
400
441
|
end
|
401
442
|
end
|
data/lib/sugarjar/util.rb
CHANGED
@@ -52,7 +52,8 @@ class SugarJar
|
|
52
52
|
end
|
53
53
|
SugarJar::Log.info('Re-running original hub command...')
|
54
54
|
s = Mixlib::ShellOut.new([which('hub')] + args).run_command
|
55
|
-
when /^fatal: could not read Username/
|
55
|
+
when /^fatal: could not read Username/, /Anonymous access denied/
|
56
|
+
|
56
57
|
# On http(s) URLs, git may prompt for username/passwd
|
57
58
|
SugarJar::Log.info(
|
58
59
|
'Hub was run but git prompted for authentication. This probably ' +
|
data/lib/sugarjar/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarjar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Dibowitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-log
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
|
-
rubygems_version: 3.
|
97
|
+
rubygems_version: 3.2.5
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: A git/github helper script
|