gitplural 1.0.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/exe/gitplural +61 -0
- data/lib/gitplural.rb +18 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f47949bb3a3e6b535f7f13b0cf92631875354cc76d0120c3c6ea984ba9d57ad1
|
4
|
+
data.tar.gz: 9a66983d1faca26f3d5bdce0154fc5aaf7f6cf65f14bbf144c6bd4b9cd5b2f55
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6fde7ea29e61fbb35c88ed91857ae0833dbb7fff0d107d18ec49d462eb9556cc17155059149ba11168ab02f38dc9153643b5cee5ca8112b85e6a3d95f938f918
|
7
|
+
data.tar.gz: 05507dc094b23a9ccee8cdaa62ab53d3911336b3499ed954aeffb0d3c539b4b35eedfdb0c0f038c3bae17c8273a7ae44641f577cbb480234cfdc9697484449b4
|
data/exe/gitplural
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative "../lib/gitplural.rb"
|
4
|
+
require 'colorize'
|
5
|
+
|
6
|
+
# Git.config(item: "user.name", value: "Maxine", global: true)
|
7
|
+
# Git.get_config_value(item: "user.email")
|
8
|
+
|
9
|
+
if ARGV[0] == "profile"
|
10
|
+
if ARGV[1] == "quickset"
|
11
|
+
# Quickly set Git identity information
|
12
|
+
|
13
|
+
puts "Please set a username:".colorize(:color => :light_blue, :mode => :bold)
|
14
|
+
username = STDIN.gets.chomp
|
15
|
+
puts "Please set an e-mail address:".colorize(:color => :light_blue, :mode => :bold)
|
16
|
+
email = STDIN.gets.chomp
|
17
|
+
|
18
|
+
puts "Setting your global Git identity to #{username} <#{email}>".colorize(:color => :light_green, :mode => :bold)
|
19
|
+
Git.config(item: "user.name", value: username, global: true)
|
20
|
+
Git.config(item: "user.email", value: email, global: true)
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
if ARGV[1] == "create"
|
24
|
+
# Create a brand new Git identity
|
25
|
+
|
26
|
+
puts "Create a new Git identity".colorize(:color => :light_green, :mode => :bold)
|
27
|
+
puts "Please set a username:"
|
28
|
+
username = STDIN.gets.chomp
|
29
|
+
puts "Please set an e-mail address"
|
30
|
+
email = STDIN.gets.chomp
|
31
|
+
|
32
|
+
cpath = File.expand_path('~/.config/gitplural/')
|
33
|
+
if !File.exist?(cpath)
|
34
|
+
Dir::mkdir(cpath, 0700)
|
35
|
+
end
|
36
|
+
|
37
|
+
File.new("#{cpath}/#{username}.identity", "w")
|
38
|
+
File.write("#{cpath}/#{username}.identity", email)
|
39
|
+
puts "Created a Git identity!".colorize(:color => :light_green, :mode => :bold)
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
if ARGV[1] == "set"
|
43
|
+
# Set your current Git identity to a saved one
|
44
|
+
|
45
|
+
username = ARGV[2]
|
46
|
+
cpath = File.expand_path('~/.config/gitplural/')
|
47
|
+
identity_file = "#{cpath}/#{username}.identity"
|
48
|
+
|
49
|
+
File.open(identity_file, "r") do |file|
|
50
|
+
# Read the content and store it in a variable
|
51
|
+
email = file.read
|
52
|
+
Git.config(item: "user.email", value: email)
|
53
|
+
Git.config(item: "user.name", value: username)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
current_username = Git.get_config_value(item: "user.name")
|
58
|
+
current_email = Git.get_config_value(item: "user.email")
|
59
|
+
|
60
|
+
puts "Current profile: #{current_username} <#{current_email}>"
|
61
|
+
end
|
data/lib/gitplural.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Git
|
2
|
+
# Configure a Git setting
|
3
|
+
#
|
4
|
+
# This method is the equivalent of
|
5
|
+
# `git config <item> <value>`
|
6
|
+
# and `--global` can be used by giving `Git.config(global: true)`
|
7
|
+
def self.config(item:, value:, global: nil)
|
8
|
+
global = "--global" if global == true
|
9
|
+
system("git config #{global} #{item} #{value}")
|
10
|
+
end
|
11
|
+
|
12
|
+
# Get a config item's current value
|
13
|
+
#
|
14
|
+
# Equivalent of running `git config <item>`
|
15
|
+
def self.get_config_value(item:)
|
16
|
+
return `git config #{item}`.chomp
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitplural
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maxine
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.0
|
27
|
+
description: A command-line manager for Git identities
|
28
|
+
email: voynich@disroot.org
|
29
|
+
executables:
|
30
|
+
- gitplural
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- exe/gitplural
|
35
|
+
- lib/gitplural.rb
|
36
|
+
homepage:
|
37
|
+
licenses: []
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubygems_version: 3.5.3
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Simple identity manager for Git
|
58
|
+
test_files: []
|