sugarjar 1.0.0 → 1.0.1
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 +22 -6
- data/lib/sugarjar/commands.rb +17 -2
- data/lib/sugarjar/repoconfig.rb +29 -11
- data/lib/sugarjar/version.rb +1 -1
- data/sugarjar.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4282936baebdd165acf740d342b5f2e75a74dcaac6b77049842e903fe675957
|
4
|
+
data.tar.gz: f200b2404a6b61444b8846f0b67af1c43585daaab22b89d6e916f3a5fe9b3b3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa37f43fbbfbd68bf3a43f58706add2a3ea981a257e41cea1b894077cad51f2f10a1d3e95d9968ea59518bbd5b6a739678bd123cd279ec67016856666521452b
|
7
|
+
data.tar.gz: 44a62d13863c21952264b4722a8fb6dd26fa3d1f548d7ab41f65d7dd0600c95f38fd333f49dfb0840734f9472ffa54050b6216a1140dc7edae2306d3b46b24b8
|
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/).
|
@@ -222,12 +224,20 @@ $ sj feature dependent-feature test-branch
|
|
222
224
|
Created feature branch dependent-feature based on test-branch
|
223
225
|
```
|
224
226
|
|
227
|
+
Additionally you can specify a `feature_prefix` in your config which will cause
|
228
|
+
`feature` to create branches prefixed with your `feature_prefix` and will also
|
229
|
+
cause `co` to checkout branches with that prefix. This is useful when organizations
|
230
|
+
use branch-based workflows and branches need to be prefixed with e.g. `$USER/`.
|
231
|
+
|
232
|
+
For example, if your prefix was `user/`, then `sj feature foo` would create
|
233
|
+
`user/foo`, and `sj co foo` would switch to `user/foo`.
|
234
|
+
|
225
235
|
## Smartlog
|
226
236
|
|
227
237
|
Smartlog will show you a tree diagram of your branches! Simply run `sj
|
228
238
|
smartlog` or `sj sl` for short.
|
229
239
|
|
230
|
-

|
231
241
|
|
232
242
|
## Pulling in suggestions from the web
|
233
243
|
|
@@ -317,6 +327,12 @@ how to handle repo-specific things. Currently there options are:
|
|
317
327
|
* `commit_template` - A path to a commit template to set in the `commit.template`
|
318
328
|
git config for this repo. Should be either a fully-qualified path, or a path
|
319
329
|
relative to the repo root.
|
330
|
+
* `include_from` - This will read an additional repoconfig file and merge it
|
331
|
+
into the one being read. The value should be relative to the root of the
|
332
|
+
repo. This will not error if the file does not exist, it is intended for
|
333
|
+
organizations to allow users to optionally extend a default repo config.
|
334
|
+
* `overwrite_from` - Same as `include_from`, but completely overwrites the
|
335
|
+
base configuration if the file is found.
|
320
336
|
|
321
337
|
Example configuration:
|
322
338
|
|
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/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.read(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
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.0.
|
4
|
+
version: 1.0.1
|
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-20 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
|