git_context 0.1.0 → 0.2.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/.circleci/config.yml +47 -0
- data/.rubocop.yml +81 -0
- data/.rubocop_todo.yml +14 -0
- data/Gemfile +18 -3
- data/Gemfile.lock +74 -1
- data/Guardfile +5 -0
- data/README.md +9 -0
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/git_context.gemspec +13 -13
- data/lefthook.yml +5 -0
- data/lib/git_context.rb +3 -1
- data/lib/git_context/cli.rb +7 -1
- data/lib/git_context/commands.rb +3 -0
- data/lib/git_context/commands/create_context.rb +3 -1
- data/lib/git_context/commands/create_profile.rb +5 -4
- data/lib/git_context/commands/help.rb +19 -0
- data/lib/git_context/commands/list_profile.rb +13 -0
- data/lib/git_context/commands/setup.rb +2 -0
- data/lib/git_context/configuration.rb +3 -0
- data/lib/git_context/interaction.rb +17 -8
- data/lib/git_context/version.rb +3 -1
- metadata +10 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0d749d3d073250eeaf34288f68e4c621eb45a2410a1388c445582d59ff31c3c7
|
|
4
|
+
data.tar.gz: 6db9512b8ffee39ae36853c43f65f9d9f3ded4154350c70d06645001dc5aa7df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b821a17ca35fc6649a59d2b6661a8663ddfc772db47224658fa4eb90757fa56e1a6be2e73b126167e7ee2fca470d5f4324c157b645b1ddbca88ba08994206f2
|
|
7
|
+
data.tar.gz: 8804f541919616da6110fbe65e5b7bdb2a50311d7c22fc36bbd3c4b347a7adf4b581afdf69498ac6a4abec7af381768c6d4db9c29856261b5e73be7700848e19
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
orbs:
|
|
3
|
+
ruby: circleci/ruby@1.1.1
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
rspec:
|
|
7
|
+
parameters:
|
|
8
|
+
ruby-version:
|
|
9
|
+
type: string
|
|
10
|
+
default: "latest"
|
|
11
|
+
codecov:
|
|
12
|
+
type: boolean
|
|
13
|
+
default: false
|
|
14
|
+
docker:
|
|
15
|
+
- image: "cimg/ruby:<< parameters.ruby-version >>"
|
|
16
|
+
executor: ruby/default
|
|
17
|
+
environment:
|
|
18
|
+
CODECOV: << parameters.codecov >>
|
|
19
|
+
steps:
|
|
20
|
+
- checkout
|
|
21
|
+
- ruby/install-deps:
|
|
22
|
+
bundler-version: 2.1.4
|
|
23
|
+
- ruby/rspec-test
|
|
24
|
+
rubocop:
|
|
25
|
+
docker:
|
|
26
|
+
- image: cimg/ruby:2.6
|
|
27
|
+
executor: ruby/default
|
|
28
|
+
steps:
|
|
29
|
+
- checkout
|
|
30
|
+
- ruby/install-deps:
|
|
31
|
+
bundler-version: 2.1.4
|
|
32
|
+
- ruby/rubocop-check
|
|
33
|
+
|
|
34
|
+
workflows:
|
|
35
|
+
build:
|
|
36
|
+
jobs:
|
|
37
|
+
- rspec:
|
|
38
|
+
name: "rspec-ruby:2.7"
|
|
39
|
+
ruby-version: "2.7"
|
|
40
|
+
codecov: true
|
|
41
|
+
- rspec:
|
|
42
|
+
name: "rspec-ruby:2.6"
|
|
43
|
+
ruby-version: "2.6"
|
|
44
|
+
- rspec:
|
|
45
|
+
name: "rspec-ruby:2.5"
|
|
46
|
+
ruby-version: "2.5"
|
|
47
|
+
- rubocop
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
Metrics/BlockLength:
|
|
4
|
+
Exclude:
|
|
5
|
+
- '**/*_spec.rb'
|
|
6
|
+
|
|
7
|
+
Style/Documentation:
|
|
8
|
+
Enabled: false
|
|
9
|
+
|
|
10
|
+
Style/FrozenStringLiteralComment:
|
|
11
|
+
Exclude:
|
|
12
|
+
- 'Gemfile'
|
|
13
|
+
- 'Guardfile'
|
|
14
|
+
- 'Rakefile'
|
|
15
|
+
- 'bin/console'
|
|
16
|
+
- 'exe/git-context'
|
|
17
|
+
- 'git_context.gemspec'
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
21
|
+
Enabled: true
|
|
22
|
+
|
|
23
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
24
|
+
Enabled: true
|
|
25
|
+
|
|
26
|
+
Lint/DuplicateElsifCondition:
|
|
27
|
+
Enabled: true
|
|
28
|
+
|
|
29
|
+
Lint/MixedRegexpCaptureTypes:
|
|
30
|
+
Enabled: true
|
|
31
|
+
|
|
32
|
+
Lint/RaiseException:
|
|
33
|
+
Enabled: true
|
|
34
|
+
|
|
35
|
+
Lint/StructNewOverride:
|
|
36
|
+
Enabled: true
|
|
37
|
+
|
|
38
|
+
Style/ArrayCoercion:
|
|
39
|
+
Enabled: true
|
|
40
|
+
|
|
41
|
+
Style/BisectedAttrAccessor:
|
|
42
|
+
Enabled: true
|
|
43
|
+
|
|
44
|
+
Style/CaseLikeIf:
|
|
45
|
+
Enabled: true
|
|
46
|
+
|
|
47
|
+
Style/ExponentialNotation:
|
|
48
|
+
Enabled: true
|
|
49
|
+
|
|
50
|
+
Style/HashAsLastArrayItem:
|
|
51
|
+
Enabled: true
|
|
52
|
+
|
|
53
|
+
Style/HashEachMethods:
|
|
54
|
+
Enabled: true
|
|
55
|
+
|
|
56
|
+
Style/HashLikeCase:
|
|
57
|
+
Enabled: true
|
|
58
|
+
|
|
59
|
+
Style/HashTransformKeys:
|
|
60
|
+
Enabled: true
|
|
61
|
+
|
|
62
|
+
Style/HashTransformValues:
|
|
63
|
+
Enabled: true
|
|
64
|
+
|
|
65
|
+
Style/RedundantAssignment:
|
|
66
|
+
Enabled: true
|
|
67
|
+
|
|
68
|
+
Style/RedundantFetchBlock:
|
|
69
|
+
Enabled: true
|
|
70
|
+
|
|
71
|
+
Style/RedundantFileExtensionInRequire:
|
|
72
|
+
Enabled: true
|
|
73
|
+
|
|
74
|
+
Style/RedundantRegexpCharacterClass:
|
|
75
|
+
Enabled: true
|
|
76
|
+
|
|
77
|
+
Style/RedundantRegexpEscape:
|
|
78
|
+
Enabled: true
|
|
79
|
+
|
|
80
|
+
Style/SlicingWithRange:
|
|
81
|
+
Enabled: true
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2020-09-05 12:25:22 UTC using RuboCop version 0.88.0.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Cop supports --auto-correct.
|
|
11
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
12
|
+
# URISchemes: http, https
|
|
13
|
+
Layout/LineLength:
|
|
14
|
+
Max: 123
|
data/Gemfile
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
# Specify your gem's dependencies in git_context.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
gem
|
|
6
|
+
group :development do
|
|
7
|
+
gem 'guard'
|
|
8
|
+
gem 'guard-rspec', require: false
|
|
9
|
+
gem 'lefthook'
|
|
10
|
+
gem 'rubocop', require: false
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
group :development, :test do
|
|
14
|
+
gem 'rake', '~> 12.0'
|
|
15
|
+
gem 'rspec', '~> 3.0'
|
|
16
|
+
gem 'rspec_junit_formatter'
|
|
17
|
+
gem 'simplecov', require: false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
group :test do
|
|
21
|
+
gem 'codecov', require: false
|
|
22
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,16 +1,61 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
git_context (0.
|
|
4
|
+
git_context (0.2.0)
|
|
5
5
|
tty-prompt (~> 0.22)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
+
ast (2.4.1)
|
|
11
|
+
codecov (0.2.10)
|
|
12
|
+
json
|
|
13
|
+
simplecov
|
|
14
|
+
coderay (1.1.3)
|
|
10
15
|
diff-lcs (1.4.4)
|
|
16
|
+
docile (1.3.2)
|
|
17
|
+
ffi (1.13.1)
|
|
18
|
+
formatador (0.2.5)
|
|
19
|
+
guard (2.16.2)
|
|
20
|
+
formatador (>= 0.2.4)
|
|
21
|
+
listen (>= 2.7, < 4.0)
|
|
22
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
23
|
+
nenv (~> 0.1)
|
|
24
|
+
notiffany (~> 0.0)
|
|
25
|
+
pry (>= 0.9.12)
|
|
26
|
+
shellany (~> 0.0)
|
|
27
|
+
thor (>= 0.18.1)
|
|
28
|
+
guard-compat (1.2.1)
|
|
29
|
+
guard-rspec (4.7.3)
|
|
30
|
+
guard (~> 2.1)
|
|
31
|
+
guard-compat (~> 1.1)
|
|
32
|
+
rspec (>= 2.99.0, < 4.0)
|
|
33
|
+
json (2.3.1)
|
|
34
|
+
lefthook (0.7.2)
|
|
35
|
+
listen (3.2.1)
|
|
36
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
37
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
38
|
+
lumberjack (1.2.7)
|
|
39
|
+
method_source (1.0.0)
|
|
40
|
+
nenv (0.3.0)
|
|
41
|
+
notiffany (0.1.3)
|
|
42
|
+
nenv (~> 0.1)
|
|
43
|
+
shellany (~> 0.0)
|
|
44
|
+
parallel (1.19.2)
|
|
45
|
+
parser (2.7.1.4)
|
|
46
|
+
ast (~> 2.4.1)
|
|
11
47
|
pastel (0.8.0)
|
|
12
48
|
tty-color (~> 0.5)
|
|
49
|
+
pry (0.13.1)
|
|
50
|
+
coderay (~> 1.1)
|
|
51
|
+
method_source (~> 1.0)
|
|
52
|
+
rainbow (3.0.0)
|
|
13
53
|
rake (12.3.3)
|
|
54
|
+
rb-fsevent (0.10.4)
|
|
55
|
+
rb-inotify (0.10.1)
|
|
56
|
+
ffi (~> 1.0)
|
|
57
|
+
regexp_parser (1.7.1)
|
|
58
|
+
rexml (3.2.4)
|
|
14
59
|
rspec (3.9.0)
|
|
15
60
|
rspec-core (~> 3.9.0)
|
|
16
61
|
rspec-expectations (~> 3.9.0)
|
|
@@ -24,6 +69,26 @@ GEM
|
|
|
24
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
25
70
|
rspec-support (~> 3.9.0)
|
|
26
71
|
rspec-support (3.9.3)
|
|
72
|
+
rspec_junit_formatter (0.4.1)
|
|
73
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
|
74
|
+
rubocop (0.88.0)
|
|
75
|
+
parallel (~> 1.10)
|
|
76
|
+
parser (>= 2.7.1.1)
|
|
77
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
78
|
+
regexp_parser (>= 1.7)
|
|
79
|
+
rexml
|
|
80
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
|
81
|
+
ruby-progressbar (~> 1.7)
|
|
82
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
83
|
+
rubocop-ast (0.1.0)
|
|
84
|
+
parser (>= 2.7.0.1)
|
|
85
|
+
ruby-progressbar (1.10.1)
|
|
86
|
+
shellany (0.0.1)
|
|
87
|
+
simplecov (0.19.0)
|
|
88
|
+
docile (~> 1.1)
|
|
89
|
+
simplecov-html (~> 0.11)
|
|
90
|
+
simplecov-html (0.12.2)
|
|
91
|
+
thor (1.0.1)
|
|
27
92
|
tty-color (0.5.2)
|
|
28
93
|
tty-cursor (0.7.1)
|
|
29
94
|
tty-prompt (0.22.0)
|
|
@@ -34,15 +99,23 @@ GEM
|
|
|
34
99
|
tty-screen (~> 0.8)
|
|
35
100
|
wisper (~> 2.0)
|
|
36
101
|
tty-screen (0.8.1)
|
|
102
|
+
unicode-display_width (1.7.0)
|
|
37
103
|
wisper (2.0.1)
|
|
38
104
|
|
|
39
105
|
PLATFORMS
|
|
40
106
|
ruby
|
|
41
107
|
|
|
42
108
|
DEPENDENCIES
|
|
109
|
+
codecov
|
|
43
110
|
git_context!
|
|
111
|
+
guard
|
|
112
|
+
guard-rspec
|
|
113
|
+
lefthook
|
|
44
114
|
rake (~> 12.0)
|
|
45
115
|
rspec (~> 3.0)
|
|
116
|
+
rspec_junit_formatter
|
|
117
|
+
rubocop
|
|
118
|
+
simplecov
|
|
46
119
|
|
|
47
120
|
BUNDLED WITH
|
|
48
121
|
2.1.4
|
data/Guardfile
ADDED
data/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# git-context
|
|
2
2
|
|
|
3
|
+
[](https://circleci.com/gh/caalberts/git_context/tree/master)
|
|
4
|
+
[](https://codecov.io/gh/caalberts/git_context)
|
|
5
|
+
|
|
3
6
|
`git-context` provides a tool to manage conditional git config.
|
|
4
7
|
|
|
5
8
|
No more committing with the wrong email in a new repository. With `git-context` you can set up a context per directory. Any git repositories within the directory would use the git config specified for that directory.
|
|
@@ -32,11 +35,13 @@ Next, create one or more user profile to contain the user name and email address
|
|
|
32
35
|
Please enter profile name: work
|
|
33
36
|
Please enter the name to be used in git config: John Doe
|
|
34
37
|
Please enter the email address to be used in git config: johndoe@company.com
|
|
38
|
+
Please enter the signing key to be used in git config: ABCD1234
|
|
35
39
|
|
|
36
40
|
$ git-context create_profile
|
|
37
41
|
Please enter profile name: fun
|
|
38
42
|
Please enter the name to be used in git config: Johnny
|
|
39
43
|
Please enter the email address to be used in git config: johnny@wut.lol
|
|
44
|
+
Please enter the signing key to be used in git config: ZYXV0987
|
|
40
45
|
```
|
|
41
46
|
|
|
42
47
|
Finally, create contexts to use a specified profile in a directory.
|
|
@@ -59,12 +64,16 @@ Now you can commit as different users easily.
|
|
|
59
64
|
John Doe
|
|
60
65
|
$ git config user.email
|
|
61
66
|
johndoe@company.com
|
|
67
|
+
$ git config user.signingKey
|
|
68
|
+
ABCD1234
|
|
62
69
|
|
|
63
70
|
$ cd /Users/john/fun/lol/wut
|
|
64
71
|
$ git config user.name
|
|
65
72
|
Johnny
|
|
66
73
|
$ git config user.email
|
|
67
74
|
johnny@wut.lol
|
|
75
|
+
$ git config user.signingKey
|
|
76
|
+
ZYXV0987
|
|
68
77
|
```
|
|
69
78
|
|
|
70
79
|
**Tip:** You could also use `git context`. `git` recognizes `git-context` as a custom command.
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'git_context'
|
|
5
5
|
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -10,5 +10,5 @@ require "git_context"
|
|
|
10
10
|
# require "pry"
|
|
11
11
|
# Pry.start
|
|
12
12
|
|
|
13
|
-
require
|
|
13
|
+
require 'irb'
|
|
14
14
|
IRB.start(__FILE__)
|
data/git_context.gemspec
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
require_relative 'lib/git_context/version'
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
|
-
spec.name =
|
|
4
|
+
spec.name = 'git_context'
|
|
5
5
|
spec.version = GitContext::VERSION
|
|
6
|
-
spec.authors = [
|
|
7
|
-
spec.email = [
|
|
6
|
+
spec.authors = ['Albert Salim']
|
|
7
|
+
spec.email = ['albertlimca@gmail.com']
|
|
8
8
|
|
|
9
|
-
spec.summary =
|
|
10
|
-
spec.description =
|
|
11
|
-
spec.homepage =
|
|
12
|
-
spec.license =
|
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
|
9
|
+
spec.summary = '`git-context` provides a tool to manage conditional git config.'
|
|
10
|
+
spec.description = '`git-context` provides a tool to manage conditional git config.'
|
|
11
|
+
spec.homepage = 'https://github.com/caalberts/git_context'
|
|
12
|
+
spec.license = 'MIT'
|
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
|
14
14
|
|
|
15
|
-
spec.metadata[
|
|
16
|
-
spec.metadata[
|
|
15
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
16
|
+
spec.metadata['source_code_uri'] = 'https://github.com/caalberts/git_context'
|
|
17
17
|
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
|
19
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
20
|
-
spec.files
|
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
21
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
22
22
|
end
|
|
23
|
-
spec.bindir =
|
|
23
|
+
spec.bindir = 'exe'
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
|
-
spec.require_paths = [
|
|
25
|
+
spec.require_paths = ['lib']
|
|
26
26
|
|
|
27
27
|
spec.add_runtime_dependency 'tty-prompt', '~> 0.22'
|
|
28
28
|
end
|
data/lefthook.yml
ADDED
data/lib/git_context.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'git_context/cli'
|
|
2
4
|
require 'git_context/commands'
|
|
3
5
|
require 'git_context/configuration'
|
|
@@ -9,5 +11,5 @@ module GitContext
|
|
|
9
11
|
|
|
10
12
|
Context = Struct.new(:work_dir, :profile_name)
|
|
11
13
|
Profile = Struct.new(:profile_name, :user)
|
|
12
|
-
User = Struct.new(:name, :email)
|
|
14
|
+
User = Struct.new(:name, :email, :signing_key)
|
|
13
15
|
end
|
data/lib/git_context/cli.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
module GitContext
|
|
3
4
|
class CLI
|
|
4
5
|
COMMAND_CLASSES = {
|
|
6
|
+
help: 'Help',
|
|
5
7
|
setup: 'Setup',
|
|
6
8
|
create_profile: 'CreateProfile',
|
|
7
|
-
create_context: 'CreateContext'
|
|
9
|
+
create_context: 'CreateContext',
|
|
10
|
+
list_profile: 'ListProfile'
|
|
8
11
|
}.freeze
|
|
9
12
|
|
|
10
13
|
def initialize(configuration)
|
|
@@ -13,11 +16,14 @@ module GitContext
|
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
def exec(command_name)
|
|
19
|
+
command_name ||= 'help'
|
|
16
20
|
command_class = command_for(command_name)
|
|
17
21
|
command = command_class.new(interaction: @interaction, configuration: @configuration)
|
|
18
22
|
command.call
|
|
19
23
|
rescue KeyError
|
|
20
24
|
warn "Unknown command #{command_name}. Supported commands are #{COMMAND_CLASSES.keys.map(&:to_s)}"
|
|
25
|
+
rescue TTY::Reader::InputInterrupt
|
|
26
|
+
warn "\nInterrupted"
|
|
21
27
|
end
|
|
22
28
|
|
|
23
29
|
private
|
data/lib/git_context/commands.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'git_context/commands/base'
|
|
3
4
|
require 'git_context/commands/create_context'
|
|
4
5
|
require 'git_context/commands/create_profile'
|
|
6
|
+
require 'git_context/commands/list_profile'
|
|
7
|
+
require 'git_context/commands/help'
|
|
5
8
|
require 'git_context/commands/setup'
|
|
6
9
|
|
|
7
10
|
module GitContext
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
module GitContext
|
|
3
4
|
module Commands
|
|
4
5
|
class CreateContext < Base
|
|
5
6
|
def call
|
|
6
7
|
profile_names = @configuration.list_profile_names
|
|
7
|
-
work_dir = @interaction.prompt_work_dir
|
|
8
|
+
work_dir = @interaction.prompt_work_dir(Dir.pwd)
|
|
8
9
|
profile_name = @interaction.prompt_profile(profile_names)
|
|
9
10
|
|
|
10
11
|
context = Context.new(work_dir, profile_name)
|
|
11
12
|
|
|
12
13
|
@configuration.add_context(context)
|
|
14
|
+
@interaction.info("Context created to use #{profile_name} within #{work_dir}.")
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
end
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
module GitContext
|
|
3
4
|
module Commands
|
|
4
5
|
class CreateProfile < Base
|
|
5
6
|
def call
|
|
6
7
|
profile_name = @interaction.prompt_profile_name
|
|
7
|
-
|
|
8
|
-
user_email = @interaction.prompt_user_email
|
|
8
|
+
input = @interaction.prompt_user_info
|
|
9
9
|
|
|
10
|
-
user = User.new(
|
|
10
|
+
user = User.new(input[:name], input[:email], input[:signing_key])
|
|
11
11
|
profile = Profile.new(profile_name, user)
|
|
12
12
|
@configuration.add_profile(profile)
|
|
13
|
+
|
|
14
|
+
@interaction.info("Profile #{profile_name} created.")
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
|
-
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GitContext
|
|
4
|
+
module Commands
|
|
5
|
+
class Help < Base
|
|
6
|
+
USAGE = <<~USAGE
|
|
7
|
+
Usage:
|
|
8
|
+
git-context setup # initialize git-context in your home directory
|
|
9
|
+
git-context create_profile # create a new profile to be used in gitconfig
|
|
10
|
+
git-context create_context # create a new context to use a profile in git repositories within a directory
|
|
11
|
+
git-context list_profile # list stored git-context profiles
|
|
12
|
+
USAGE
|
|
13
|
+
|
|
14
|
+
def call
|
|
15
|
+
puts USAGE
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'fileutils'
|
|
2
4
|
require 'pathname'
|
|
3
5
|
|
|
@@ -24,6 +26,7 @@ module GitContext
|
|
|
24
26
|
|
|
25
27
|
`git config -f "#{profile_file}" --add user.name "#{profile.user.name}"`
|
|
26
28
|
`git config -f "#{profile_file}" --add user.email "#{profile.user.email}"`
|
|
29
|
+
`git config -f "#{profile_file}" --add user.signingKey "#{profile.user.signing_key}"`
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
def list_profile_names
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'tty-prompt'
|
|
3
4
|
|
|
4
5
|
module GitContext
|
|
@@ -7,24 +8,32 @@ module GitContext
|
|
|
7
8
|
@prompt = prompt
|
|
8
9
|
end
|
|
9
10
|
|
|
10
|
-
def prompt_work_dir
|
|
11
|
-
@prompt.ask('Please enter working directory:')
|
|
11
|
+
def prompt_work_dir(default_dir)
|
|
12
|
+
@prompt.ask('Please enter working directory:', default: default_dir, required: true)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def prompt_profile(saved_profiles)
|
|
15
|
-
@prompt.select('Please select from existing profiles:', saved_profiles)
|
|
16
|
+
@prompt.select('Please select from existing profiles:', saved_profiles, cycle: true)
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def prompt_profile_name
|
|
19
|
-
@prompt.ask('Please enter profile name:')
|
|
20
|
+
@prompt.ask('Please enter profile name:', required: true)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def prompt_user_info
|
|
24
|
+
@prompt.collect do
|
|
25
|
+
key(:name).ask('Please enter the name to be used in git config:')
|
|
26
|
+
key(:email).ask('Please enter the name to be used in git config:')
|
|
27
|
+
key(:signing_key).ask('Please enter the signing key to be used in git config:')
|
|
28
|
+
end
|
|
20
29
|
end
|
|
21
30
|
|
|
22
|
-
def
|
|
23
|
-
@prompt.
|
|
31
|
+
def show(message)
|
|
32
|
+
@prompt.say(message)
|
|
24
33
|
end
|
|
25
34
|
|
|
26
|
-
def
|
|
27
|
-
@prompt.
|
|
35
|
+
def info(message)
|
|
36
|
+
@prompt.ok(message)
|
|
28
37
|
end
|
|
29
38
|
end
|
|
30
39
|
end
|
data/lib/git_context/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: git_context
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Albert Salim
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-09-
|
|
11
|
+
date: 2020-09-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: tty-prompt
|
|
@@ -32,11 +32,15 @@ executables:
|
|
|
32
32
|
extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
|
34
34
|
files:
|
|
35
|
+
- ".circleci/config.yml"
|
|
35
36
|
- ".gitignore"
|
|
36
37
|
- ".rspec"
|
|
38
|
+
- ".rubocop.yml"
|
|
39
|
+
- ".rubocop_todo.yml"
|
|
37
40
|
- ".tool-versions"
|
|
38
41
|
- Gemfile
|
|
39
42
|
- Gemfile.lock
|
|
43
|
+
- Guardfile
|
|
40
44
|
- LICENSE.txt
|
|
41
45
|
- README.md
|
|
42
46
|
- Rakefile
|
|
@@ -44,12 +48,15 @@ files:
|
|
|
44
48
|
- bin/setup
|
|
45
49
|
- exe/git-context
|
|
46
50
|
- git_context.gemspec
|
|
51
|
+
- lefthook.yml
|
|
47
52
|
- lib/git_context.rb
|
|
48
53
|
- lib/git_context/cli.rb
|
|
49
54
|
- lib/git_context/commands.rb
|
|
50
55
|
- lib/git_context/commands/base.rb
|
|
51
56
|
- lib/git_context/commands/create_context.rb
|
|
52
57
|
- lib/git_context/commands/create_profile.rb
|
|
58
|
+
- lib/git_context/commands/help.rb
|
|
59
|
+
- lib/git_context/commands/list_profile.rb
|
|
53
60
|
- lib/git_context/commands/setup.rb
|
|
54
61
|
- lib/git_context/configuration.rb
|
|
55
62
|
- lib/git_context/interaction.rb
|
|
@@ -75,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
75
82
|
- !ruby/object:Gem::Version
|
|
76
83
|
version: '0'
|
|
77
84
|
requirements: []
|
|
78
|
-
rubygems_version: 3.
|
|
85
|
+
rubygems_version: 3.1.4
|
|
79
86
|
signing_key:
|
|
80
87
|
specification_version: 4
|
|
81
88
|
summary: "`git-context` provides a tool to manage conditional git config."
|