Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The configuration file `~/.gitpassport` is rather self-explanatory:
[general]
enable_hook = True
sleep_duration = 0.5
quiet = False

[passport 0]
email = email_0@example.com
Expand All @@ -77,6 +78,8 @@ name = name_1
service = gitlab.com
```

Setting `quiet` to `True` will stop `git-passport.py` from printing the active passport upon default execution (To see the active passport with `quiet` enabled, you must pass the `-a` option).

Adjust the existing sections and add as many passports as you like by following
the section scheme.

Expand Down
13 changes: 7 additions & 6 deletions git-passport.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@
exit(0)

if local_email and local_name:
case.active_identity(
config,
local_email,
local_name,
local_url
)
if not config["quiet"]:
case.active_identity(
config,
local_email,
local_name,
local_url
)
sys.exit(0)

if local_url:
Expand Down
14 changes: 13 additions & 1 deletion passport/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def preset(filename):
preset["general"] = {}
preset["general"]["enable_hook"] = "True"
preset["general"]["sleep_duration"] = "0.75"
preset["general"]["quiet"] = "False"

preset["passport 0"] = {}
preset["passport 0"]["email"] = "email_0@example.com"
Expand Down Expand Up @@ -87,7 +88,8 @@ def validate_scheme(filename):
"enable_hook",
"name",
"service",
"sleep_duration"
"sleep_duration",
"quiet"
])

# Create sets containing non-whitelisted section and option names
Expand Down Expand Up @@ -148,6 +150,7 @@ def validate_values(filename):
email: E-Mail scheme
sleep_duration: Float
enable_hook: Boolean
quiet: Boolean

Args:
filename (str): The complete `filepath` of the configuration file
Expand Down Expand Up @@ -188,6 +191,14 @@ def filter_email(config):

print(msg)
return False

try:
raw_config.getboolean("general", "quiet")
except ValueError:
msg = "E > Configuration > quiet: Expecting True or False."

print(msg)
return False

# Quit if we have wrong float values
try:
Expand Down Expand Up @@ -222,6 +233,7 @@ def passport(config):

config = {}
config["enable_hook"] = raw_config.getboolean("general", "enable_hook")
config["quiet"] = raw_config.getboolean("general", "quiet")
config["sleep_duration"] = raw_config.getfloat("general", "sleep_duration")
config["git_passports"] = dict(enumerate(passport(raw_config)))

Expand Down