sugarjar 1.0.0 → 1.1.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 +4 -4
- data/Gemfile +0 -1
- data/README.md +32 -20
- data/lib/sugarjar/commands.rb +17 -2
- data/lib/sugarjar/config.rb +2 -2
- data/lib/sugarjar/repoconfig.rb +29 -11
- data/lib/sugarjar/version.rb +1 -1
- data/sugarjar.gemspec +7 -1
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 017705b23c86a5a5c6f1695c5e7dabca591409d2f99039c592d9db14822d7cd2
|
4
|
+
data.tar.gz: e41d40f68013573e5074772d061aa8c55fc69f860d6f63688219a995ab409abc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54d411046b2f5cab10e97d740e0c4c335a17ec9c4cefcd363720f06660ba4a3310d8ab2a48e057f9047b16d116e30e0e1b082d78953fe9570cee3bee2d14f6f0
|
7
|
+
data.tar.gz: fefe49ca8cd8a8b8c80139a10cc874d24a08808349cae3a71237f47b263502c2fafc92a12d947bcf9b1c17a977bd4ffff8c3956f17bd0f1a18f68dfb566d8b2f
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,12 +5,14 @@
|
|
5
5
|
[](https://github.com/jaymzh/sugarjar/actions?query=workflow%3A%22DCO+Check%22)
|
6
6
|
|
7
7
|
> [!IMPORTANT]
|
8
|
-
>
|
9
|
-
> instead of this
|
8
|
+
> If you are a _new_ user, I suggest looking at [Sapling](https://sapling-scm.com/)
|
9
|
+
> instead of this. This was written as a stop-gap to approximate some features
|
10
10
|
> of the Facebook/Meta internal development tools before they were released.
|
11
|
-
> Now that those tools have been open-sourced and work with GitHub,
|
12
|
-
> likely to
|
13
|
-
>
|
11
|
+
> Now that those tools have been open-sourced and work with GitHub, new users
|
12
|
+
> will likely want to start there. Sapling is far more feature rich, faster,
|
13
|
+
> and have more development resources behind them. SugarJar is a smaller
|
14
|
+
> transition, and for the time being I'm maintaining it for all existing users,
|
15
|
+
> and for those who may not yet be ready for the transition to Sapling.
|
14
16
|
|
15
17
|
Welcome to SugarJar - a git/github helper. It needs one of the GitHub CLI's:
|
16
18
|
either [gh](https://cli.github.com/) or the older [hub](https://hub.github.com/).
|
@@ -33,19 +35,16 @@ list here, and if so, use your package manager (or `gem`) to install it:
|
|
33
35
|
|
34
36
|
[](https://repology.org/project/sugarjar/versions)
|
35
37
|
|
36
|
-
For
|
37
|
-
23.04 release. Until then, for supported LTS releases starting 20.04 (focal)
|
38
|
-
and the latest non-LTS release, you can use [this PPA](
|
39
|
-
https://launchpad.net/~michel-slm/+archive/ubuntu/sugarjar) maintained by the
|
40
|
-
Debian package maintainer.
|
38
|
+
For MacOS users, you can use our Homebrew Tap:
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
```shell
|
41
|
+
homebrew tap jaymzh/sugarjar
|
42
|
+
homebrew install sugarjar
|
43
|
+
```
|
44
|
+
|
45
|
+
You can also weigh in on [this
|
46
|
+
PR](https://github.com/Homebrew/homebrew-core/pull/157910) and tell the
|
47
|
+
Homebrew folks you'd like to see it in core.
|
49
48
|
|
50
49
|
Finally, if none of those work for you, you can clone this repo and run it
|
51
50
|
directly from there.
|
@@ -222,12 +221,20 @@ $ sj feature dependent-feature test-branch
|
|
222
221
|
Created feature branch dependent-feature based on test-branch
|
223
222
|
```
|
224
223
|
|
224
|
+
Additionally you can specify a `feature_prefix` in your config which will cause
|
225
|
+
`feature` to create branches prefixed with your `feature_prefix` and will also
|
226
|
+
cause `co` to checkout branches with that prefix. This is useful when organizations
|
227
|
+
use branch-based workflows and branches need to be prefixed with e.g. `$USER/`.
|
228
|
+
|
229
|
+
For example, if your prefix was `user/`, then `sj feature foo` would create
|
230
|
+
`user/foo`, and `sj co foo` would switch to `user/foo`.
|
231
|
+
|
225
232
|
## Smartlog
|
226
233
|
|
227
234
|
Smartlog will show you a tree diagram of your branches! Simply run `sj
|
228
235
|
smartlog` or `sj sl` for short.
|
229
236
|
|
230
|
-

|
231
238
|
|
232
239
|
## Pulling in suggestions from the web
|
233
240
|
|
@@ -317,6 +324,12 @@ how to handle repo-specific things. Currently there options are:
|
|
317
324
|
* `commit_template` - A path to a commit template to set in the `commit.template`
|
318
325
|
git config for this repo. Should be either a fully-qualified path, or a path
|
319
326
|
relative to the repo root.
|
327
|
+
* `include_from` - This will read an additional repoconfig file and merge it
|
328
|
+
into the one being read. The value should be relative to the root of the
|
329
|
+
repo. This will not error if the file does not exist, it is intended for
|
330
|
+
organizations to allow users to optionally extend a default repo config.
|
331
|
+
* `overwrite_from` - Same as `include_from`, but completely overwrites the
|
332
|
+
base configuration if the file is found.
|
320
333
|
|
321
334
|
Example configuration:
|
322
335
|
|
@@ -390,8 +403,7 @@ default to prefer `gh` in 1.0.0.
|
|
390
403
|
**I'd like to package SugarJar for my favorite distro/OS, is that OK?**
|
391
404
|
|
392
405
|
Of course! But I'd appreciate you emailing me to give me a heads up. Doing so
|
393
|
-
will allow me to make sure it shows up in the Repology badge above
|
394
|
-
stop building Omnibus packages for whatever distro.
|
406
|
+
will allow me to make sure it shows up in the Repology badge above.
|
395
407
|
|
396
408
|
**What platforms does it work on?**
|
397
409
|
|
data/lib/sugarjar/commands.rb
CHANGED
@@ -21,6 +21,7 @@ class SugarJar
|
|
21
21
|
@ignore_dirty = options['ignore_dirty']
|
22
22
|
@ignore_prerun_failure = options['ignore_prerun_failure']
|
23
23
|
@repo_config = SugarJar::RepoConfig.config
|
24
|
+
SugarJar::Log.debug("Repoconfig: #{@repo_config}")
|
24
25
|
@color = options['color']
|
25
26
|
@feature_prefix = options['feature_prefix']
|
26
27
|
@checks = {}
|
@@ -95,6 +96,15 @@ class SugarJar
|
|
95
96
|
|
96
97
|
def co(*args)
|
97
98
|
assert_in_repo
|
99
|
+
# Pop the last arguement, which is _probably_ a branch name
|
100
|
+
# and then add any featureprefix, and if _that_ is a branch
|
101
|
+
# name, replace the last arguement with that
|
102
|
+
name = args.last
|
103
|
+
bname = fprefix(name) unless all_local_branches.include?(name)
|
104
|
+
if all_local_branches.include?(bname)
|
105
|
+
SugarJar::Log.debug("Featurepefixing #{name} -> #{bname}")
|
106
|
+
args[-1] = bname
|
107
|
+
end
|
98
108
|
s = git('checkout', *args)
|
99
109
|
SugarJar::Log.info(s.stderr + s.stdout.chomp)
|
100
110
|
end
|
@@ -296,7 +306,7 @@ class SugarJar
|
|
296
306
|
end
|
297
307
|
if gh?
|
298
308
|
SugarJar::Log.trace("Running: gh pr create #{args.join(' ')}")
|
299
|
-
system(which('gh'), 'pr', 'create', *args)
|
309
|
+
system(which('gh'), 'pr', 'create', '--fill', *args)
|
300
310
|
else
|
301
311
|
SugarJar::Log.trace("Running: hub pull-request #{args.join(' ')}")
|
302
312
|
system(which('hub'), 'pull-request', *args)
|
@@ -553,7 +563,12 @@ class SugarJar
|
|
553
563
|
SugarJar::Log.debug("Running #{type} #{check}")
|
554
564
|
|
555
565
|
short = check.split.first
|
556
|
-
|
566
|
+
if short.include?('/')
|
567
|
+
short = File.join(repo_root, short) unless short.start_with?('/')
|
568
|
+
unless File.exist?(short)
|
569
|
+
SugarJar::Log.error("Configured #{type} #{short} does not exist!")
|
570
|
+
end
|
571
|
+
elsif !which_nofail(short)
|
557
572
|
SugarJar::Log.error("Configured #{type} #{short} does not exist!")
|
558
573
|
return false
|
559
574
|
end
|
data/lib/sugarjar/config.rb
CHANGED
@@ -23,9 +23,9 @@ class SugarJar
|
|
23
23
|
c = DEFAULTS.dup
|
24
24
|
_find_ordered_files.each do |f|
|
25
25
|
SugarJar::Log.debug("Loading config #{f}")
|
26
|
-
data = YAML.
|
26
|
+
data = YAML.safe_load_file(f)
|
27
27
|
# an empty file is a `nil` which you can't merge
|
28
|
-
c.merge!(YAML.
|
28
|
+
c.merge!(YAML.safe_load_file(f)) if data
|
29
29
|
SugarJar::Log.debug("Modified config: #{c}")
|
30
30
|
end
|
31
31
|
c
|
data/lib/sugarjar/repoconfig.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative 'util'
|
2
2
|
require_relative 'log'
|
3
3
|
require 'yaml'
|
4
|
+
require 'deep_merge'
|
4
5
|
|
5
6
|
class SugarJar
|
6
7
|
# This parses SugarJar repoconfigs (not to be confused with configs).
|
@@ -10,23 +11,40 @@ class SugarJar
|
|
10
11
|
|
11
12
|
CONFIG_NAME = '.sugarjar.yaml'.freeze
|
12
13
|
|
13
|
-
def self.
|
14
|
-
::File.join(repo_root,
|
14
|
+
def self.repo_config_path(config)
|
15
|
+
::File.join(repo_root, config)
|
15
16
|
end
|
16
17
|
|
17
|
-
def self.
|
18
|
+
def self.hash_from_file(config_file)
|
19
|
+
SugarJar::Log.debug("Loading repo config: #{config_file}")
|
20
|
+
YAML.safe_load_file(config_file)
|
21
|
+
end
|
22
|
+
|
23
|
+
# wrapper for File.exist to make unittests easier
|
24
|
+
def self.config_file?(config_file)
|
25
|
+
File.exist?(config_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.config(config = CONFIG_NAME)
|
29
|
+
data = {}
|
18
30
|
unless in_repo
|
19
31
|
SugarJar::Log.debug('Not in repo, skipping repoconfig load')
|
20
|
-
return
|
32
|
+
return data
|
21
33
|
end
|
22
|
-
|
23
|
-
if
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
34
|
+
config_file = repo_config_path(config)
|
35
|
+
data = hash_from_file(config_file) if config_file?(config_file)
|
36
|
+
if data['overwrite_from'] && config_file?(data['overwrite_from'])
|
37
|
+
SugarJar::Log.debug(
|
38
|
+
"Attempting overwrite_from #{data['overwrite_from']}",
|
39
|
+
)
|
40
|
+
data = config(data['overwrite_from'])
|
41
|
+
data.delete('overwrite_from')
|
42
|
+
elsif data['include_from'] && config_file?(data['include_from'])
|
43
|
+
SugarJar::Log.debug("Attempting include_from #{data['include_from']}")
|
44
|
+
data.deep_merge!(config(data['include_from']))
|
45
|
+
data.delete('include_from')
|
29
46
|
end
|
47
|
+
data
|
30
48
|
end
|
31
49
|
end
|
32
50
|
end
|
data/lib/sugarjar/version.rb
CHANGED
data/sugarjar.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.email = ['phil@ipom.com']
|
9
9
|
spec.license = 'Apache-2.0'
|
10
10
|
spec.homepage = 'https://github.com/jaymzh/sugarjar'
|
11
|
-
spec.required_ruby_version = '>=
|
11
|
+
spec.required_ruby_version = '>= 3.1'
|
12
12
|
docs = %w{README.md LICENSE Gemfile sugarjar.gemspec}
|
13
13
|
spec.extra_rdoc_files = docs
|
14
14
|
spec.executables << 'sj'
|
@@ -17,10 +17,16 @@ Gem::Specification.new do |spec|
|
|
17
17
|
Dir.glob('bin/*') +
|
18
18
|
docs
|
19
19
|
|
20
|
+
spec.add_dependency 'deep_merge'
|
20
21
|
spec.add_dependency 'mixlib-log'
|
21
22
|
spec.add_dependency 'mixlib-shellout'
|
22
23
|
spec.add_dependency 'pastel'
|
23
24
|
spec.metadata = {
|
24
25
|
'rubygems_mfa_required' => 'true',
|
26
|
+
'bug_tracker_uri' => 'https://github.com/jaymzh/sugarjar/issues',
|
27
|
+
'changelog_uri' =>
|
28
|
+
'https://github.com/jaymzh/sugarjar/blob/main/CHANGELOG.md',
|
29
|
+
'homepage_uri' => 'https://github.com/jaymzh/sugajar',
|
30
|
+
'source_code_uri' => 'https://github.com/jaymzh/sugarjar',
|
25
31
|
}
|
26
32
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarjar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Dibowitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: deep_merge
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: mixlib-log
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,10 @@ licenses:
|
|
80
94
|
- Apache-2.0
|
81
95
|
metadata:
|
82
96
|
rubygems_mfa_required: 'true'
|
97
|
+
bug_tracker_uri: https://github.com/jaymzh/sugarjar/issues
|
98
|
+
changelog_uri: https://github.com/jaymzh/sugarjar/blob/main/CHANGELOG.md
|
99
|
+
homepage_uri: https://github.com/jaymzh/sugajar
|
100
|
+
source_code_uri: https://github.com/jaymzh/sugarjar
|
83
101
|
post_install_message:
|
84
102
|
rdoc_options: []
|
85
103
|
require_paths:
|
@@ -88,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
106
|
requirements:
|
89
107
|
- - ">="
|
90
108
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
109
|
+
version: '3.1'
|
92
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
111
|
requirements:
|
94
112
|
- - ">="
|