git_context 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +13 -1
- data/.gitignore +4 -0
- data/.tool-versions +1 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +68 -0
- data/lib/git_context.rb +27 -2
- data/lib/git_context/cli.rb +1 -0
- data/lib/git_context/commands.rb +1 -0
- data/lib/git_context/commands/delete_profile.rb +13 -0
- data/lib/git_context/commands/help.rb +1 -0
- data/lib/git_context/commands/setup.rb +1 -1
- data/lib/git_context/configuration.rb +45 -73
- data/lib/git_context/interaction.rb +4 -0
- data/lib/git_context/storage.rb +9 -0
- data/lib/git_context/storage/git.rb +116 -0
- data/lib/git_context/storage/yml.rb +65 -0
- data/lib/git_context/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e60bd7daf714b6c070888204e98523dbc07f312dada914f7d0403da772ea46d1
|
4
|
+
data.tar.gz: 1c38f849025ff3387e644a3e9102fda430d73091bfa2897ce932b8693179efdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a9c5ad38b56f93180a41859d4a32675eed0855ca846b36263a3797f1802cd9b62b6381d5aba6466be8cb15916338167807c5c059a57557699d3bf5c752549fd
|
7
|
+
data.tar.gz: 9757e7d8b562b18e2cb562c39bda171ead91dff5732dec41a15ef157a12255fa2c65ab9a318108043afb00ab69153a28031e55b4174f227acc6f8e8ac8372464
|
data/.circleci/config.yml
CHANGED
@@ -23,13 +23,24 @@ jobs:
|
|
23
23
|
- ruby/rspec-test
|
24
24
|
rubocop:
|
25
25
|
docker:
|
26
|
-
- image: cimg/ruby:2.
|
26
|
+
- image: cimg/ruby:2.7.2
|
27
27
|
executor: ruby/default
|
28
28
|
steps:
|
29
29
|
- checkout
|
30
30
|
- ruby/install-deps:
|
31
31
|
bundler-version: 2.1.4
|
32
32
|
- ruby/rubocop-check
|
33
|
+
features:
|
34
|
+
docker:
|
35
|
+
- image: cimg/ruby:2.7.2
|
36
|
+
executor: ruby/default
|
37
|
+
steps:
|
38
|
+
- checkout
|
39
|
+
- ruby/install-deps:
|
40
|
+
bundler-version: 2.1.4
|
41
|
+
- run:
|
42
|
+
name: Feature tests
|
43
|
+
command: bundle exec rspec features
|
33
44
|
|
34
45
|
workflows:
|
35
46
|
build:
|
@@ -45,3 +56,4 @@ workflows:
|
|
45
56
|
name: "rspec-ruby:2.5"
|
46
57
|
ruby-version: "2.5"
|
47
58
|
- rubocop
|
59
|
+
- features
|
data/.gitignore
CHANGED
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 2.7.3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -7,11 +7,59 @@ PATH
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
activesupport (6.1.3.2)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
|
+
zeitwerk (~> 2.3)
|
16
|
+
aruba (1.1.0)
|
17
|
+
childprocess (>= 2.0, < 5.0)
|
18
|
+
contracts (~> 0.16.0)
|
19
|
+
cucumber (>= 2.4, < 7.0)
|
20
|
+
rspec-expectations (~> 3.4)
|
21
|
+
thor (~> 1.0)
|
10
22
|
ast (2.4.1)
|
23
|
+
builder (3.2.4)
|
24
|
+
childprocess (4.0.0)
|
11
25
|
codecov (0.2.10)
|
12
26
|
json
|
13
27
|
simplecov
|
14
28
|
coderay (1.1.3)
|
29
|
+
concurrent-ruby (1.1.8)
|
30
|
+
contracts (0.16.1)
|
31
|
+
cucumber (6.0.0)
|
32
|
+
builder (~> 3.2, >= 3.2.4)
|
33
|
+
cucumber-core (~> 9.0, >= 9.0.0)
|
34
|
+
cucumber-create-meta (~> 4.0, >= 4.0.0)
|
35
|
+
cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
|
36
|
+
cucumber-gherkin (~> 18.1, >= 18.1.0)
|
37
|
+
cucumber-html-formatter (~> 13.0, >= 13.0.0)
|
38
|
+
cucumber-messages (~> 15.0, >= 15.0.0)
|
39
|
+
cucumber-wire (~> 5.0, >= 5.0.0)
|
40
|
+
diff-lcs (~> 1.4, >= 1.4.4)
|
41
|
+
mime-types (~> 3.3, >= 3.3.1)
|
42
|
+
multi_test (~> 0.1, >= 0.1.2)
|
43
|
+
sys-uname (~> 1.2, >= 1.2.2)
|
44
|
+
cucumber-core (9.0.0)
|
45
|
+
cucumber-gherkin (~> 18.1, >= 18.1.0)
|
46
|
+
cucumber-messages (~> 15.0, >= 15.0.0)
|
47
|
+
cucumber-tag-expressions (~> 3.0, >= 3.0.1)
|
48
|
+
cucumber-create-meta (4.0.0)
|
49
|
+
cucumber-messages (~> 15.0, >= 15.0.0)
|
50
|
+
sys-uname (~> 1.2, >= 1.2.2)
|
51
|
+
cucumber-cucumber-expressions (12.1.1)
|
52
|
+
cucumber-gherkin (18.1.1)
|
53
|
+
cucumber-messages (~> 15.0, >= 15.0.0)
|
54
|
+
cucumber-html-formatter (13.0.0)
|
55
|
+
cucumber-messages (~> 15.0, >= 15.0.0)
|
56
|
+
cucumber-messages (15.0.0)
|
57
|
+
protobuf-cucumber (~> 3.10, >= 3.10.8)
|
58
|
+
cucumber-tag-expressions (3.0.1)
|
59
|
+
cucumber-wire (5.0.0)
|
60
|
+
cucumber-core (~> 9.0, >= 9.0.0)
|
61
|
+
cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
|
62
|
+
cucumber-messages (~> 15.0, >= 15.0.0)
|
15
63
|
diff-lcs (1.4.4)
|
16
64
|
docile (1.3.2)
|
17
65
|
ffi (1.13.1)
|
@@ -30,6 +78,8 @@ GEM
|
|
30
78
|
guard (~> 2.1)
|
31
79
|
guard-compat (~> 1.1)
|
32
80
|
rspec (>= 2.99.0, < 4.0)
|
81
|
+
i18n (1.8.10)
|
82
|
+
concurrent-ruby (~> 1.0)
|
33
83
|
json (2.3.1)
|
34
84
|
lefthook (0.7.2)
|
35
85
|
listen (3.2.1)
|
@@ -37,6 +87,12 @@ GEM
|
|
37
87
|
rb-inotify (~> 0.9, >= 0.9.10)
|
38
88
|
lumberjack (1.2.7)
|
39
89
|
method_source (1.0.0)
|
90
|
+
middleware (0.1.0)
|
91
|
+
mime-types (3.3.1)
|
92
|
+
mime-types-data (~> 3.2015)
|
93
|
+
mime-types-data (3.2021.0225)
|
94
|
+
minitest (5.14.4)
|
95
|
+
multi_test (0.1.2)
|
40
96
|
nenv (0.3.0)
|
41
97
|
notiffany (0.1.3)
|
42
98
|
nenv (~> 0.1)
|
@@ -46,6 +102,11 @@ GEM
|
|
46
102
|
ast (~> 2.4.1)
|
47
103
|
pastel (0.8.0)
|
48
104
|
tty-color (~> 0.5)
|
105
|
+
protobuf-cucumber (3.10.8)
|
106
|
+
activesupport (>= 3.2)
|
107
|
+
middleware
|
108
|
+
thor
|
109
|
+
thread_safe
|
49
110
|
pry (0.13.1)
|
50
111
|
coderay (~> 1.1)
|
51
112
|
method_source (~> 1.0)
|
@@ -88,7 +149,10 @@ GEM
|
|
88
149
|
docile (~> 1.1)
|
89
150
|
simplecov-html (~> 0.11)
|
90
151
|
simplecov-html (0.12.2)
|
152
|
+
sys-uname (1.2.2)
|
153
|
+
ffi (~> 1.1)
|
91
154
|
thor (1.0.1)
|
155
|
+
thread_safe (0.3.6)
|
92
156
|
tty-color (0.5.2)
|
93
157
|
tty-cursor (0.7.1)
|
94
158
|
tty-prompt (0.22.0)
|
@@ -99,13 +163,17 @@ GEM
|
|
99
163
|
tty-screen (~> 0.8)
|
100
164
|
wisper (~> 2.0)
|
101
165
|
tty-screen (0.8.1)
|
166
|
+
tzinfo (2.0.4)
|
167
|
+
concurrent-ruby (~> 1.0)
|
102
168
|
unicode-display_width (1.7.0)
|
103
169
|
wisper (2.0.1)
|
170
|
+
zeitwerk (2.4.2)
|
104
171
|
|
105
172
|
PLATFORMS
|
106
173
|
ruby
|
107
174
|
|
108
175
|
DEPENDENCIES
|
176
|
+
aruba (~> 1.1.0)
|
109
177
|
codecov
|
110
178
|
git_context!
|
111
179
|
guard
|
data/lib/git_context.rb
CHANGED
@@ -4,12 +4,37 @@ require 'git_context/cli'
|
|
4
4
|
require 'git_context/commands'
|
5
5
|
require 'git_context/configuration'
|
6
6
|
require 'git_context/interaction'
|
7
|
+
require 'git_context/storage'
|
7
8
|
require 'git_context/version'
|
8
9
|
|
9
10
|
module GitContext
|
11
|
+
GITCONFIG_FILE = '.gitconfig'
|
12
|
+
BASE_STORAGE_DIR = '.gitcontext'
|
13
|
+
CONFIG_FILE = 'config.yml'
|
14
|
+
PROFILES_DIR = 'profiles'
|
15
|
+
CONTEXTS_FILE = 'contexts'
|
16
|
+
|
10
17
|
class Error < StandardError; end
|
11
18
|
|
12
|
-
Context = Struct.new(:work_dir, :profile_name)
|
13
|
-
|
19
|
+
Context = Struct.new(:work_dir, :profile_name) do
|
20
|
+
def serialize
|
21
|
+
{
|
22
|
+
'work_dir' => work_dir,
|
23
|
+
'profile_name' => profile_name
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Profile = Struct.new(:profile_name, :user) do
|
29
|
+
def serialize
|
30
|
+
{
|
31
|
+
'profile_name' => profile_name,
|
32
|
+
'name' => user.name,
|
33
|
+
'email' => user.email,
|
34
|
+
'signing_key' => user.signing_key
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
14
39
|
User = Struct.new(:name, :email, :signing_key)
|
15
40
|
end
|
data/lib/git_context/cli.rb
CHANGED
data/lib/git_context/commands.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'git_context/commands/base'
|
4
4
|
require 'git_context/commands/create_context'
|
5
5
|
require 'git_context/commands/create_profile'
|
6
|
+
require 'git_context/commands/delete_profile'
|
6
7
|
require 'git_context/commands/list_profile'
|
7
8
|
require 'git_context/commands/help'
|
8
9
|
require 'git_context/commands/setup'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GitContext
|
4
|
+
module Commands
|
5
|
+
class DeleteProfile < Base
|
6
|
+
def call
|
7
|
+
stored_profiles = @configuration.list_profile_names
|
8
|
+
to_be_deleted = @interaction.prompt_delete_profile(stored_profiles)
|
9
|
+
@configuration.delete_profile(to_be_deleted)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -8,6 +8,7 @@ module GitContext
|
|
8
8
|
git-context setup # initialize git-context in your home directory
|
9
9
|
git-context create_profile # create a new profile to be used in gitconfig
|
10
10
|
git-context create_context # create a new context to use a profile in git repositories within a directory
|
11
|
+
git-context delete_profile # delete a stored git-context profile
|
11
12
|
git-context list_profile # list stored git-context profiles
|
12
13
|
USAGE
|
13
14
|
|
@@ -1,108 +1,80 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
-
require 'pathname'
|
5
4
|
|
6
5
|
module GitContext
|
7
|
-
class
|
8
|
-
|
9
|
-
PROFILES_DIR = 'profiles'
|
10
|
-
CONTEXTS_FILENAME = 'contexts'
|
6
|
+
class ConfigData
|
7
|
+
attr_reader :home, :profiles, :contexts
|
11
8
|
|
12
|
-
def initialize(
|
13
|
-
@
|
9
|
+
def initialize(home)
|
10
|
+
@home = home
|
11
|
+
@profiles = []
|
12
|
+
@contexts = []
|
14
13
|
end
|
15
14
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def add_profile(profile)
|
24
|
-
profile_file = profile_filepath(profile.profile_name)
|
25
|
-
touch_file(profile_file)
|
26
|
-
|
27
|
-
`git config -f "#{profile_file}" --add user.name "#{profile.user.name}"`
|
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}"`
|
30
|
-
end
|
31
|
-
|
32
|
-
def list_profile_names
|
33
|
-
Dir.entries(profiles_dir) - %w[. ..]
|
34
|
-
end
|
35
|
-
|
36
|
-
def delete_profile(profile)
|
37
|
-
profile_file = profile_filepath(profile.profile_name)
|
38
|
-
delete_file(profile_file)
|
39
|
-
end
|
40
|
-
|
41
|
-
def add_context(context)
|
42
|
-
profile_file = profile_filepath(context.profile_name)
|
43
|
-
|
44
|
-
`git config -f "#{contexts_filepath}" --add "includeIf.gitdir:#{context.work_dir}/.path" "#{profile_file}"`
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def profile_filepath(profile_name)
|
50
|
-
profiles_dir.join(profile_name)
|
15
|
+
def serialize
|
16
|
+
{
|
17
|
+
'profiles' => profiles.map(&:serialize),
|
18
|
+
'contexts' => contexts.map(&:serialize)
|
19
|
+
}
|
51
20
|
end
|
21
|
+
end
|
52
22
|
|
53
|
-
|
54
|
-
|
55
|
-
end
|
23
|
+
class Configuration
|
24
|
+
attr_reader :home, :config_data, :yaml, :git, :storages
|
56
25
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
26
|
+
def initialize(home)
|
27
|
+
@home = home
|
28
|
+
@config_data = ConfigData.new(@home)
|
29
|
+
@yaml = Storage::YML.new(@config_data)
|
30
|
+
@git = Storage::Git.new(@config_data)
|
60
31
|
|
61
|
-
|
62
|
-
|
32
|
+
@yaml.load
|
33
|
+
@storages = [@yaml, @git]
|
63
34
|
end
|
64
35
|
|
65
|
-
def
|
66
|
-
|
36
|
+
def setup
|
37
|
+
create_base_dir
|
38
|
+
setup_storage
|
67
39
|
end
|
68
40
|
|
69
|
-
def
|
70
|
-
|
41
|
+
def add_profile(profile)
|
42
|
+
config_data.profiles << profile
|
43
|
+
save_into_storage
|
71
44
|
end
|
72
45
|
|
73
|
-
def
|
74
|
-
|
46
|
+
def delete_profile(profile_name)
|
47
|
+
config_data.profiles.delete_if { |profile| profile.profile_name == profile_name }
|
48
|
+
save_into_storage
|
75
49
|
end
|
76
50
|
|
77
|
-
def
|
78
|
-
|
51
|
+
def list_profile_names
|
52
|
+
config_data.profiles.map(&:profile_name).sort
|
79
53
|
end
|
80
54
|
|
81
|
-
def
|
82
|
-
|
55
|
+
def add_context(context)
|
56
|
+
config_data.contexts << context
|
57
|
+
config_data.contexts.sort_by!(&:work_dir)
|
83
58
|
|
84
|
-
|
59
|
+
save_into_storage
|
85
60
|
end
|
86
61
|
|
87
|
-
|
88
|
-
include_path = `git config -f "#{global_gitconfig_path}" include.path`
|
89
|
-
include_path.include?(contexts_filepath.to_s)
|
90
|
-
end
|
62
|
+
private
|
91
63
|
|
92
|
-
def
|
93
|
-
|
64
|
+
def setup_storage
|
65
|
+
storages.each(&:setup)
|
94
66
|
end
|
95
67
|
|
96
|
-
def
|
97
|
-
|
68
|
+
def save_into_storage
|
69
|
+
storages.each(&:save)
|
98
70
|
end
|
99
71
|
|
100
|
-
def
|
101
|
-
FileUtils.
|
72
|
+
def create_base_dir
|
73
|
+
FileUtils.mkdir(git_context_dir) unless FileTest.exists?(git_context_dir)
|
102
74
|
end
|
103
75
|
|
104
|
-
def
|
105
|
-
|
76
|
+
def git_context_dir
|
77
|
+
File.join(home, BASE_STORAGE_DIR)
|
106
78
|
end
|
107
79
|
end
|
108
80
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module GitContext
|
6
|
+
module Storage
|
7
|
+
class Git
|
8
|
+
attr_reader :config
|
9
|
+
|
10
|
+
def initialize(config)
|
11
|
+
@config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup
|
15
|
+
create_contexts_file
|
16
|
+
create_profiles_dir
|
17
|
+
|
18
|
+
include(global_gitconfig_path, contexts_filepath)
|
19
|
+
end
|
20
|
+
|
21
|
+
def reset
|
22
|
+
FileUtils.rm(contexts_filepath)
|
23
|
+
FileUtils.rm_r(profiles_dir)
|
24
|
+
|
25
|
+
create_contexts_file
|
26
|
+
create_profiles_dir
|
27
|
+
end
|
28
|
+
|
29
|
+
def save
|
30
|
+
reset
|
31
|
+
save_profiles
|
32
|
+
save_contexts
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def save_contexts
|
38
|
+
config.contexts.each do |context|
|
39
|
+
profile_file = profile_filepath(context.profile_name)
|
40
|
+
|
41
|
+
add_context(contexts_filepath, context.work_dir, profile_file)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def save_profiles
|
46
|
+
config.profiles.each do |profile|
|
47
|
+
profile_file = profile_filepath(profile.profile_name)
|
48
|
+
touch_file(profile_file)
|
49
|
+
|
50
|
+
add_profile(profile_file, profile)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def include(gitconfig_path, contexts_filepath)
|
55
|
+
return if included?(gitconfig_path, contexts_filepath)
|
56
|
+
|
57
|
+
`git config -f "#{gitconfig_path}" --add "include.path" "#{contexts_filepath}"`
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_profile(profile_file, profile)
|
61
|
+
`git config -f "#{profile_file}" --add user.name "#{profile.user.name}"`
|
62
|
+
`git config -f "#{profile_file}" --add user.email "#{profile.user.email}"`
|
63
|
+
`git config -f "#{profile_file}" --add user.signingKey "#{profile.user.signing_key}"`
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_context(contexts_file, dir, profile_file)
|
67
|
+
`git config -f "#{contexts_file}" --add "includeIf.gitdir:#{dir}/.path" "#{profile_file}"`
|
68
|
+
end
|
69
|
+
|
70
|
+
def included?(gitconfig_path, contexts_filepath)
|
71
|
+
include_path = `git config -f "#{gitconfig_path}" include.path`
|
72
|
+
include_path.include?(contexts_filepath)
|
73
|
+
end
|
74
|
+
|
75
|
+
def home
|
76
|
+
config.home
|
77
|
+
end
|
78
|
+
|
79
|
+
def create_contexts_file
|
80
|
+
touch_file(contexts_filepath)
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_profiles_dir
|
84
|
+
create_dir(profiles_dir)
|
85
|
+
end
|
86
|
+
|
87
|
+
def global_gitconfig_path
|
88
|
+
File.join(home, GITCONFIG_FILE)
|
89
|
+
end
|
90
|
+
|
91
|
+
def contexts_filepath
|
92
|
+
File.join(git_context_dir, CONTEXTS_FILE)
|
93
|
+
end
|
94
|
+
|
95
|
+
def git_context_dir
|
96
|
+
File.join(home, BASE_STORAGE_DIR)
|
97
|
+
end
|
98
|
+
|
99
|
+
def profiles_dir
|
100
|
+
File.join(git_context_dir, PROFILES_DIR)
|
101
|
+
end
|
102
|
+
|
103
|
+
def profile_filepath(profile_name)
|
104
|
+
File.join(profiles_dir, profile_name)
|
105
|
+
end
|
106
|
+
|
107
|
+
def touch_file(config_file_path)
|
108
|
+
FileUtils.touch(config_file_path)
|
109
|
+
end
|
110
|
+
|
111
|
+
def create_dir(dir)
|
112
|
+
FileUtils.mkdir(dir) unless FileTest.exists?(dir)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module GitContext
|
6
|
+
module Storage
|
7
|
+
class YML
|
8
|
+
attr_reader :config
|
9
|
+
|
10
|
+
def initialize(config)
|
11
|
+
@config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup
|
15
|
+
return if FileTest.exist?(config_filepath)
|
16
|
+
|
17
|
+
FileUtils.touch(config_filepath)
|
18
|
+
end
|
19
|
+
|
20
|
+
def load
|
21
|
+
return unless config_filepath && FileTest.exist?(config_filepath)
|
22
|
+
|
23
|
+
load_profiles_from_file
|
24
|
+
load_contexts_from_file
|
25
|
+
end
|
26
|
+
|
27
|
+
def save
|
28
|
+
File.open(config_filepath, 'w') do |file|
|
29
|
+
file.write(YAML.dump(serialized_data))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def load_profiles_from_file
|
36
|
+
content['profiles']&.each do |profile|
|
37
|
+
user = User.new(profile['name'], profile['email'], profile['signing_key'])
|
38
|
+
config.profiles << Profile.new(profile['profile_name'], user)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def load_contexts_from_file
|
43
|
+
content['contexts']&.each do |context|
|
44
|
+
config.contexts << Context.new(context['work_dir'], context['profile_name'])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def content
|
49
|
+
@content ||= YAML.load_file(config_filepath) || {}
|
50
|
+
end
|
51
|
+
|
52
|
+
def serialized_data
|
53
|
+
config.serialize
|
54
|
+
end
|
55
|
+
|
56
|
+
def config_filepath
|
57
|
+
File.join(git_context_dir, CONFIG_FILE)
|
58
|
+
end
|
59
|
+
|
60
|
+
def git_context_dir
|
61
|
+
File.join(config.home, BASE_STORAGE_DIR)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
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.3.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:
|
11
|
+
date: 2021-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|
@@ -55,11 +55,15 @@ files:
|
|
55
55
|
- lib/git_context/commands/base.rb
|
56
56
|
- lib/git_context/commands/create_context.rb
|
57
57
|
- lib/git_context/commands/create_profile.rb
|
58
|
+
- lib/git_context/commands/delete_profile.rb
|
58
59
|
- lib/git_context/commands/help.rb
|
59
60
|
- lib/git_context/commands/list_profile.rb
|
60
61
|
- lib/git_context/commands/setup.rb
|
61
62
|
- lib/git_context/configuration.rb
|
62
63
|
- lib/git_context/interaction.rb
|
64
|
+
- lib/git_context/storage.rb
|
65
|
+
- lib/git_context/storage/git.rb
|
66
|
+
- lib/git_context/storage/yml.rb
|
63
67
|
- lib/git_context/version.rb
|
64
68
|
homepage: https://github.com/caalberts/git_context
|
65
69
|
licenses:
|
@@ -82,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
86
|
- !ruby/object:Gem::Version
|
83
87
|
version: '0'
|
84
88
|
requirements: []
|
85
|
-
rubygems_version: 3.1.
|
89
|
+
rubygems_version: 3.1.6
|
86
90
|
signing_key:
|
87
91
|
specification_version: 4
|
88
92
|
summary: "`git-context` provides a tool to manage conditional git config."
|