Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
22972d578c | |||
a48f4638c0 | |||
b50de01653 | |||
888acd355f | |||
92b4d3872f | |||
b4702c1a72 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
@@ -60,6 +60,12 @@ python ait.py --config custom
|
||||
|
||||
This command will look for a configuration file named `ait.custom.config`.
|
||||
|
||||
### Fallback Configuration File search
|
||||
|
||||
As a fallback, if no configuration file is found, the script will search for it in the user's home directory under `~\.ait\*`.
|
||||
|
||||
You can also provide a user wide configuration file by placing it in the `~\.ait\` directory.
|
||||
|
||||
### Command-Line Options
|
||||
|
||||
- `--config`: Path to a JSON config file or a keyword to identify a specific config (`ait.<KEYWORD>.config`). Default is `ait.config.json`.
|
||||
|
24
ait.py
24
ait.py
@@ -22,7 +22,8 @@ def load_config(config_path):
|
||||
def resolve_config_path(config_input):
|
||||
"""
|
||||
Resolves the configuration file path. If a single word is provided,
|
||||
it looks for a file named 'ait.WORD.config' in the current directory.
|
||||
it looks for a file named 'ait.WORD.config.json' in the current directory first,
|
||||
then in a '.ait' directory in the user's home directory.
|
||||
|
||||
Parameters:
|
||||
- config_input (str): The input provided via the command-line argument.
|
||||
@@ -30,9 +31,24 @@ def resolve_config_path(config_input):
|
||||
Returns:
|
||||
- str: The resolved path to the configuration file.
|
||||
"""
|
||||
# If it's a keyword, construct the potential filenames
|
||||
if not config_input.endswith(".json"):
|
||||
config_input = f"ait.{config_input}.config.json"
|
||||
return config_input
|
||||
config_filename = f"ait.{config_input}.config.json"
|
||||
else:
|
||||
config_filename = config_input
|
||||
|
||||
# Check in the current directory
|
||||
if os.path.exists(config_filename):
|
||||
return config_filename
|
||||
|
||||
# Check in the user's home directory under .ait/
|
||||
home_directory = os.path.expanduser("~")
|
||||
user_config_path = os.path.join(home_directory, ".ait", config_filename)
|
||||
if os.path.exists(user_config_path):
|
||||
return user_config_path
|
||||
|
||||
# If nothing found, return the filename (it will fail later if non-existent)
|
||||
return config_filename
|
||||
|
||||
def run_git_commands(diff_expression, log_expression):
|
||||
"""
|
||||
@@ -48,7 +64,7 @@ def run_git_commands(diff_expression, log_expression):
|
||||
diff_command = ["git", "diff", diff_expression]
|
||||
diff_result = subprocess.run(diff_command, capture_output=True, text=True)
|
||||
|
||||
log_command = ["git", "log", log_expression, "--pretty=format:%h %s%n%b%n---%n"]
|
||||
log_command = ["git", "log", log_expression, "--pretty=\"format:%h%n%ad%n%s%n%n%b%n---%n\""]
|
||||
log_result = subprocess.run(log_command, capture_output=True, text=True)
|
||||
|
||||
return diff_result.stdout, log_result.stdout
|
||||
|
Reference in New Issue
Block a user