git-copilot 0.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +24 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +96 -0
- data/LICENSE.txt +21 -0
- data/README.md +126 -0
- data/Rakefile +20 -0
- data/bin/console +15 -0
- data/bin/git-copilot +9 -0
- data/bin/setup +8 -0
- data/git-copilot.gemspec +34 -0
- data/lib/git/copilot.rb +23 -0
- data/lib/git/copilot/cli.rb +70 -0
- data/lib/git/copilot/cli/user.rb +38 -0
- data/lib/git/copilot/configuration.rb +59 -0
- data/lib/git/copilot/version.rb +9 -0
- data/tmp/.gitkeep +0 -0
- metadata +192 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 71d6d6d5ec79dcc60ede3ddc73ab7fe42ce741fbdaaf7155f3b3e163cf0864ff
|
|
4
|
+
data.tar.gz: 308eb67d9e45b0c26910b7ab2887492e1038be93b5b13c8d0ae4517d96bd5013
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4f3c9b37c43a79269298a42e70dd03c838b2d229e5c0b08f58465a17301dfb6900c6c4e14c984d23cc74481c78ba66f3027909f4b02744a2e996933f61bb3a9a
|
|
7
|
+
data.tar.gz: 1a7ef02ffdab51702956fcbb8c132bbd4e72d1c19d925fe8e551191a0eab5b743e88d02d287b03d31f54d28342424d4486aaaeb35b52669eb3effde57a14aa20
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
AllCops:
|
|
3
|
+
TargetRubyVersion: 2.4
|
|
4
|
+
|
|
5
|
+
Metrics/LineLength:
|
|
6
|
+
Max: 120
|
|
7
|
+
|
|
8
|
+
Style/ClassAndModuleChildren:
|
|
9
|
+
EnforcedStyle: compact
|
|
10
|
+
|
|
11
|
+
Style/Documentation:
|
|
12
|
+
Enabled: false
|
|
13
|
+
|
|
14
|
+
Style/FormatStringToken:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
17
|
+
Style/StringLiterals:
|
|
18
|
+
EnforcedStyle: double_quotes
|
|
19
|
+
|
|
20
|
+
Style/TrailingCommaInArguments:
|
|
21
|
+
EnforcedStyleForMultiline: comma
|
|
22
|
+
|
|
23
|
+
Style/TrailingCommaInLiteral:
|
|
24
|
+
EnforcedStyleForMultiline: comma
|
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
git-copilot
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.4.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
git-copilot (0.1.0)
|
|
5
|
+
thor (~> 0.20)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
ast (2.4.0)
|
|
11
|
+
backports (3.11.1)
|
|
12
|
+
builder (3.2.3)
|
|
13
|
+
byebug (10.0.0)
|
|
14
|
+
coderay (1.1.2)
|
|
15
|
+
cucumber (3.1.0)
|
|
16
|
+
builder (>= 2.1.2)
|
|
17
|
+
cucumber-core (~> 3.1.0)
|
|
18
|
+
cucumber-expressions (~> 5.0.4)
|
|
19
|
+
cucumber-wire (~> 0.0.1)
|
|
20
|
+
diff-lcs (~> 1.3)
|
|
21
|
+
gherkin (~> 5.0)
|
|
22
|
+
multi_json (>= 1.7.5, < 2.0)
|
|
23
|
+
multi_test (>= 0.1.2)
|
|
24
|
+
cucumber-core (3.1.0)
|
|
25
|
+
backports (>= 3.8.0)
|
|
26
|
+
cucumber-tag_expressions (~> 1.1.0)
|
|
27
|
+
gherkin (>= 5.0.0)
|
|
28
|
+
cucumber-expressions (5.0.13)
|
|
29
|
+
cucumber-tag_expressions (1.1.1)
|
|
30
|
+
cucumber-wire (0.0.1)
|
|
31
|
+
diff-lcs (1.3)
|
|
32
|
+
docile (1.1.5)
|
|
33
|
+
gherkin (5.0.0)
|
|
34
|
+
json (2.1.0)
|
|
35
|
+
method_source (0.9.0)
|
|
36
|
+
multi_json (1.13.1)
|
|
37
|
+
multi_test (0.1.2)
|
|
38
|
+
parallel (1.12.1)
|
|
39
|
+
parser (2.4.0.2)
|
|
40
|
+
ast (~> 2.3)
|
|
41
|
+
powerpack (0.1.1)
|
|
42
|
+
pry (0.11.3)
|
|
43
|
+
coderay (~> 1.1.0)
|
|
44
|
+
method_source (~> 0.9.0)
|
|
45
|
+
pry-byebug (3.6.0)
|
|
46
|
+
byebug (~> 10.0)
|
|
47
|
+
pry (~> 0.10)
|
|
48
|
+
rainbow (3.0.0)
|
|
49
|
+
rake (10.5.0)
|
|
50
|
+
rspec (3.7.0)
|
|
51
|
+
rspec-core (~> 3.7.0)
|
|
52
|
+
rspec-expectations (~> 3.7.0)
|
|
53
|
+
rspec-mocks (~> 3.7.0)
|
|
54
|
+
rspec-core (3.7.1)
|
|
55
|
+
rspec-support (~> 3.7.0)
|
|
56
|
+
rspec-expectations (3.7.0)
|
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
58
|
+
rspec-support (~> 3.7.0)
|
|
59
|
+
rspec-mocks (3.7.0)
|
|
60
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
61
|
+
rspec-support (~> 3.7.0)
|
|
62
|
+
rspec-support (3.7.1)
|
|
63
|
+
rubocop (0.52.1)
|
|
64
|
+
parallel (~> 1.10)
|
|
65
|
+
parser (>= 2.4.0.2, < 3.0)
|
|
66
|
+
powerpack (~> 0.1)
|
|
67
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
68
|
+
ruby-progressbar (~> 1.7)
|
|
69
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
70
|
+
rubocop-rspec (1.22.2)
|
|
71
|
+
rubocop (>= 0.52.1)
|
|
72
|
+
ruby-progressbar (1.9.0)
|
|
73
|
+
simplecov (0.15.1)
|
|
74
|
+
docile (~> 1.1.0)
|
|
75
|
+
json (>= 1.8, < 3)
|
|
76
|
+
simplecov-html (~> 0.10.0)
|
|
77
|
+
simplecov-html (0.10.2)
|
|
78
|
+
thor (0.20.0)
|
|
79
|
+
unicode-display_width (1.3.0)
|
|
80
|
+
|
|
81
|
+
PLATFORMS
|
|
82
|
+
ruby
|
|
83
|
+
|
|
84
|
+
DEPENDENCIES
|
|
85
|
+
bundler (~> 1.16)
|
|
86
|
+
cucumber (~> 3.1)
|
|
87
|
+
git-copilot!
|
|
88
|
+
pry-byebug (~> 3.6)
|
|
89
|
+
rake (~> 10.0)
|
|
90
|
+
rspec (~> 3.0)
|
|
91
|
+
rubocop (~> 0.52)
|
|
92
|
+
rubocop-rspec (~> 1.22)
|
|
93
|
+
simplecov (~> 0.15)
|
|
94
|
+
|
|
95
|
+
BUNDLED WITH
|
|
96
|
+
1.16.0
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Matthew Patterson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Git Co-pilot
|
|
2
|
+
|
|
3
|
+
Easily populate Git commit messages when pairing
|
|
4
|
+
|
|
5
|
+
Git Co-pilot provides a Git commit message template that can be pre-populated with one or more `Co-authored-by` trailers when you are pair programming. These trailers tell GitHub that multiple users authored a commit. See [GitHub's docs](https://help.github.com/articles/creating-a-commit-with-multiple-authors/) for more information on this feature.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Git Co-pilot requires Ruby 2.2 or newer.
|
|
10
|
+
|
|
11
|
+
Install it from RubyGems:
|
|
12
|
+
|
|
13
|
+
$ gem install git-copilot
|
|
14
|
+
|
|
15
|
+
Then run `git-copilot init` to finish the setup. This will (optionally) add a `git copilot` alias and configure `git commit` to use a template managed by Git Co-pilot.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
These instructions assume that you've set up the Git alias `git copilot`. If you haven't, just run `git-copilot` instead of `git copilot`.
|
|
20
|
+
|
|
21
|
+
### Pairing and Soloing
|
|
22
|
+
|
|
23
|
+
When you are pair programming, run `git copilot pair` with the username(s) of the people you're pairing with.
|
|
24
|
+
|
|
25
|
+
$ git copilot pair jake
|
|
26
|
+
$ git commit
|
|
27
|
+
# Write a commit message in your editor
|
|
28
|
+
|
|
29
|
+
$ git show --no-patch
|
|
30
|
+
commit 419493356d6ced752974104acf9698a94525a6da
|
|
31
|
+
Author: John Smith <john.smith@example.com>
|
|
32
|
+
Date: Mon Feb 12 16:24:03 2018 -0500
|
|
33
|
+
|
|
34
|
+
Refactor FooService
|
|
35
|
+
|
|
36
|
+
Co-authored-by: Jake Johnson <jake.johnson@example.com>
|
|
37
|
+
|
|
38
|
+
You can also specify multiple pairs -- as many as you want!
|
|
39
|
+
|
|
40
|
+
$ git copilot pair jake george
|
|
41
|
+
$ git commit
|
|
42
|
+
# Write a commit message in your editor
|
|
43
|
+
|
|
44
|
+
$ git show --no-patch
|
|
45
|
+
commit b1abdf4693e2da8977bf23de5765a3654532aba4
|
|
46
|
+
Author: John Smith <john.smith@example.com>
|
|
47
|
+
Date: Mon Feb 12 16:24:03 2018 -0500
|
|
48
|
+
|
|
49
|
+
Refactor FooService
|
|
50
|
+
|
|
51
|
+
Co-authored-by: Jake Johnson <jake.johnson@example.com>
|
|
52
|
+
Co-authored-by: George Geoffries <george.geoffries@example.com>
|
|
53
|
+
|
|
54
|
+
When it's time to go solo, run `git copilot solo`.
|
|
55
|
+
|
|
56
|
+
$ git copilot solo
|
|
57
|
+
$ git commit
|
|
58
|
+
# Write a commit message in your editor
|
|
59
|
+
|
|
60
|
+
$ git show --no-patch
|
|
61
|
+
commit f438fbe9e8a9ef775821eb3c9ffd04a9e28216fa
|
|
62
|
+
Author: John Smith <john.smith@example.com>
|
|
63
|
+
Date: Mon Feb 12 16:24:03 2018 -0500
|
|
64
|
+
|
|
65
|
+
Fix failing test from refactor
|
|
66
|
+
|
|
67
|
+
### Managing Pairs
|
|
68
|
+
|
|
69
|
+
Before you can `git copilot pair` with someone, `git copilot` needs to know about them.
|
|
70
|
+
|
|
71
|
+
To add a pair, run `git copilot user add` with a "username" for the person you want to add. This username could be the person's username on GitHub or a company network, but it doesn't have to be; it's just how you will reference the user in `git copilot pair` commands.
|
|
72
|
+
|
|
73
|
+
$ git copilot user add jake
|
|
74
|
+
Git author name: Jake Johnson
|
|
75
|
+
Git author email: jake.johnson@example.com
|
|
76
|
+
|
|
77
|
+
Added Jake Johnson <jake.johnson@example.com> as "jake"!
|
|
78
|
+
|
|
79
|
+
If the user is on GitHub, you can import this information with the `--github` flag. If the details from GitHub are correct, you can just press "Enter" insted of re-entering them.
|
|
80
|
+
|
|
81
|
+
$ git copilot user add --github jake
|
|
82
|
+
Git author name: (Jake Johnson) # Just hit enter
|
|
83
|
+
Git author email: (jake.johnson@example.com) # Just hit enter
|
|
84
|
+
|
|
85
|
+
Added Jake Johnson <jake.johnson@example.com> as "jake"!
|
|
86
|
+
|
|
87
|
+
To remove a user, run `git copilot user remove` with the username you want to remove.
|
|
88
|
+
|
|
89
|
+
$ git copilot user remove jake
|
|
90
|
+
Remove Jake Johnson <jake.johnson@example.com>? y
|
|
91
|
+
Removed jake!
|
|
92
|
+
|
|
93
|
+
To list all users that Git Co-pilot knows about, run `git copilot user list`.
|
|
94
|
+
|
|
95
|
+
$ git copilot user list
|
|
96
|
+
jake Jake Johnson <jake.johnson@example.com>
|
|
97
|
+
george George Geoffries <george.geoffries@example.com>
|
|
98
|
+
|
|
99
|
+
### Advanced Configuration
|
|
100
|
+
|
|
101
|
+
Git Co-pilot stores all of its data at `$HOME/.gitcopilot.yml`. The structure of the file looks something like this:
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
---
|
|
105
|
+
template: |-
|
|
106
|
+
# Write your commit message here
|
|
107
|
+
|
|
108
|
+
%{coauthors}
|
|
109
|
+
users:
|
|
110
|
+
jake:
|
|
111
|
+
name: Jake Johnson
|
|
112
|
+
email: jake.johnson@example.com
|
|
113
|
+
george:
|
|
114
|
+
name: George Geoffries
|
|
115
|
+
email: george.geoffries@example.com
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
## Contributing
|
|
121
|
+
|
|
122
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/atmattpatt/git-copilot.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
|
|
5
|
+
require "bundler/gem_tasks"
|
|
6
|
+
require "cucumber/rake/task"
|
|
7
|
+
require "rspec/core/rake_task"
|
|
8
|
+
require "rubocop/rake_task"
|
|
9
|
+
|
|
10
|
+
Cucumber::Rake::Task.new(:features)
|
|
11
|
+
|
|
12
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
13
|
+
|
|
14
|
+
RuboCop::RakeTask.new(:rubocop)
|
|
15
|
+
|
|
16
|
+
task :clean do
|
|
17
|
+
FileUtils.rm_rf("coverage")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
task default: %i[clean features spec rubocop]
|
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "git/copilot"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require "irb"
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/git-copilot
ADDED
data/bin/setup
ADDED
data/git-copilot.gemspec
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require "git/copilot/version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "git-copilot"
|
|
9
|
+
spec.version = Git::Copilot::VERSION
|
|
10
|
+
spec.authors = ["Matthew Patterson"]
|
|
11
|
+
spec.email = ["matthew.s.patterson@gmail.com"]
|
|
12
|
+
|
|
13
|
+
spec.summary = "Easily populate Git commit messages when pairing"
|
|
14
|
+
spec.homepage = "https://github.com/atmattpatt/git-copilot"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "bin"
|
|
21
|
+
spec.executables = %w[git-copilot]
|
|
22
|
+
spec.require_paths = %w[lib]
|
|
23
|
+
|
|
24
|
+
spec.add_dependency "thor", "~> 0.20"
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
27
|
+
spec.add_development_dependency "cucumber", "~> 3.1"
|
|
28
|
+
spec.add_development_dependency "pry-byebug", "~> 3.6"
|
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
31
|
+
spec.add_development_dependency "rubocop", "~> 0.52"
|
|
32
|
+
spec.add_development_dependency "rubocop-rspec", "~> 1.22"
|
|
33
|
+
spec.add_development_dependency "simplecov", "~> 0.15"
|
|
34
|
+
end
|
data/lib/git/copilot.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "thor"
|
|
4
|
+
require "yaml"
|
|
5
|
+
|
|
6
|
+
# TODO: Remove this
|
|
7
|
+
if ENV["COVERAGE"] == "1"
|
|
8
|
+
require "securerandom"
|
|
9
|
+
require "simplecov"
|
|
10
|
+
SimpleCov.command_name "git-copilot-#{SecureRandom.hex(4)}"
|
|
11
|
+
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
|
12
|
+
SimpleCov.start
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# rubocop:disable Style/ClassAndModuleChildren
|
|
16
|
+
module Git
|
|
17
|
+
module Copilot
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
# rubocop:enable Style/ClassAndModuleChildren
|
|
21
|
+
|
|
22
|
+
require "git/copilot/cli"
|
|
23
|
+
require "git/copilot/version"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "git/copilot/configuration"
|
|
4
|
+
require "git/copilot/cli/user"
|
|
5
|
+
|
|
6
|
+
module Git::Copilot
|
|
7
|
+
class CLI < Thor
|
|
8
|
+
include Configuration
|
|
9
|
+
|
|
10
|
+
desc "init", "Initialize Git Co-pilot"
|
|
11
|
+
option :force, aliases: [:f], type: :boolean, desc: "Overwrite existing configuration files"
|
|
12
|
+
def init
|
|
13
|
+
if File.exist?(config_file_path) && !options[:force]
|
|
14
|
+
return say_status "ERROR", "Configuration file already exists", :red
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
say "Writing configuration file to #{config_file_path}"
|
|
18
|
+
File.write(config_file_path, empty_configuration)
|
|
19
|
+
|
|
20
|
+
solo
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "solo", "Prepare a commit message template for solo work"
|
|
24
|
+
def solo
|
|
25
|
+
write_template
|
|
26
|
+
set_git_commit_template
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "pair USERNAME...", "Prepare a commit message template for pairing"
|
|
30
|
+
def pair(*usernames)
|
|
31
|
+
authors = usernames.map do |username|
|
|
32
|
+
users.fetch(username) do
|
|
33
|
+
say_status "WARNING", "Unknown user #{username}", :yellow
|
|
34
|
+
next
|
|
35
|
+
end
|
|
36
|
+
end.compact
|
|
37
|
+
|
|
38
|
+
write_template(authors: authors)
|
|
39
|
+
set_git_commit_template
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc "user SUBCOMMAND", "Manage users that Git Co-pilot knows about"
|
|
43
|
+
subcommand "user", User
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def write_template(authors: [])
|
|
48
|
+
File.write(commit_message_template_path, template(authors: authors))
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def set_git_commit_template
|
|
52
|
+
`git config commit.template #{commit_message_template_path}`
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def template(authors: [])
|
|
56
|
+
coauthored_by_lines = authors.map do |user|
|
|
57
|
+
format("Co-authored-by: %{name} <%{email}>", name: user.name, email: user.email)
|
|
58
|
+
end.join("\n")
|
|
59
|
+
|
|
60
|
+
format(configuration["template"], coauthors: coauthored_by_lines)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def empty_configuration
|
|
64
|
+
YAML.dump(
|
|
65
|
+
"template" => "# Write your commit message here\n\n%{coauthors}",
|
|
66
|
+
"users" => {},
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Git::Copilot::CLI < Thor
|
|
4
|
+
class User < Thor
|
|
5
|
+
include Git::Copilot::Configuration
|
|
6
|
+
|
|
7
|
+
desc "add USERNAME", "Add a user identified by USERNAME"
|
|
8
|
+
def add(username)
|
|
9
|
+
name = ask "Git author name:"
|
|
10
|
+
email = ask "Git author email:"
|
|
11
|
+
|
|
12
|
+
user = add_user(username, name, email)
|
|
13
|
+
commit_config
|
|
14
|
+
|
|
15
|
+
say %(Added #{user.to_committer} as "#{user.username}")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "remove USERNAME", "Remove a user identified by USERNAME"
|
|
19
|
+
def remove(username)
|
|
20
|
+
user = users.fetch(username) do
|
|
21
|
+
return say_status "WARNING", "Unknown user #{username}", :yellow
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
users.delete(username) && commit_config if yes?("Remove #{user.to_committer}?")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc "list", "List users that Git Co-pilot knows about"
|
|
28
|
+
def list
|
|
29
|
+
return say "No users found" if users.empty?
|
|
30
|
+
|
|
31
|
+
user_table = users.map do |username, user|
|
|
32
|
+
[username, user.to_committer]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
print_table user_table
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Git::Copilot::Configuration
|
|
4
|
+
User = Struct.new(:username, :name, :email)
|
|
5
|
+
class User
|
|
6
|
+
def to_committer
|
|
7
|
+
format "%{name} <%{email}>", name: name, email: email
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def to_h
|
|
11
|
+
{
|
|
12
|
+
"name" => name,
|
|
13
|
+
"email" => email,
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
|
|
20
|
+
def config_dir
|
|
21
|
+
File.expand_path(ENV["HOME"])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def config_file_path
|
|
25
|
+
File.join(config_dir, ".gitcopilot.yml")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def commit_message_template_path
|
|
29
|
+
File.join(config_dir, ".gitcopilot-commit-template")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def configuration
|
|
33
|
+
@configuration ||= YAML.safe_load(File.read(config_file_path))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def config_to_commit
|
|
37
|
+
{
|
|
38
|
+
"template" => configuration["template"],
|
|
39
|
+
"users" => users.each_with_object({}) do |(username, user), memo|
|
|
40
|
+
memo[username.to_s] = user.to_h
|
|
41
|
+
end,
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def commit_config
|
|
46
|
+
File.write(config_file_path, YAML.dump(config_to_commit))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def users
|
|
50
|
+
@users ||= configuration.fetch("users", {}).each_with_object({}) do |(username, data), memo|
|
|
51
|
+
memo[username] = User.new(username, data["name"], data["email"])
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def add_user(username, name, email)
|
|
56
|
+
user = User.new(username, name, email)
|
|
57
|
+
users.store(user.username, user)
|
|
58
|
+
end
|
|
59
|
+
end
|
data/tmp/.gitkeep
ADDED
|
File without changes
|
metadata
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: git-copilot
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Matthew Patterson
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.20'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.20'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.16'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.16'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: cucumber
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.1'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.1'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry-byebug
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.6'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.6'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rake
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '10.0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '10.0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rspec
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '3.0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '3.0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rubocop
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0.52'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0.52'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: rubocop-rspec
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '1.22'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '1.22'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: simplecov
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0.15'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0.15'
|
|
139
|
+
description:
|
|
140
|
+
email:
|
|
141
|
+
- matthew.s.patterson@gmail.com
|
|
142
|
+
executables:
|
|
143
|
+
- git-copilot
|
|
144
|
+
extensions: []
|
|
145
|
+
extra_rdoc_files: []
|
|
146
|
+
files:
|
|
147
|
+
- ".gitignore"
|
|
148
|
+
- ".rspec"
|
|
149
|
+
- ".rubocop.yml"
|
|
150
|
+
- ".ruby-gemset"
|
|
151
|
+
- ".ruby-version"
|
|
152
|
+
- ".travis.yml"
|
|
153
|
+
- Gemfile
|
|
154
|
+
- Gemfile.lock
|
|
155
|
+
- LICENSE.txt
|
|
156
|
+
- README.md
|
|
157
|
+
- Rakefile
|
|
158
|
+
- bin/console
|
|
159
|
+
- bin/git-copilot
|
|
160
|
+
- bin/setup
|
|
161
|
+
- git-copilot.gemspec
|
|
162
|
+
- lib/git/copilot.rb
|
|
163
|
+
- lib/git/copilot/cli.rb
|
|
164
|
+
- lib/git/copilot/cli/user.rb
|
|
165
|
+
- lib/git/copilot/configuration.rb
|
|
166
|
+
- lib/git/copilot/version.rb
|
|
167
|
+
- tmp/.gitkeep
|
|
168
|
+
homepage: https://github.com/atmattpatt/git-copilot
|
|
169
|
+
licenses:
|
|
170
|
+
- MIT
|
|
171
|
+
metadata: {}
|
|
172
|
+
post_install_message:
|
|
173
|
+
rdoc_options: []
|
|
174
|
+
require_paths:
|
|
175
|
+
- lib
|
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0'
|
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
|
+
requirements:
|
|
183
|
+
- - ">="
|
|
184
|
+
- !ruby/object:Gem::Version
|
|
185
|
+
version: '0'
|
|
186
|
+
requirements: []
|
|
187
|
+
rubyforge_project:
|
|
188
|
+
rubygems_version: 2.7.4
|
|
189
|
+
signing_key:
|
|
190
|
+
specification_version: 4
|
|
191
|
+
summary: Easily populate Git commit messages when pairing
|
|
192
|
+
test_files: []
|