Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7f4c75e606 | ||
a6dde44a84 | |||
5cc850b8a9 | |||
ad14e31b75 | |||
22972d578c | |||
a48f4638c0 | |||
b50de01653 | |||
888acd355f | |||
92b4d3872f | |||
b4702c1a72 | |||
aec4c78c6a | |||
59ac01451f | |||
c9386f8b32 | |||
fbcb87152f | |||
e054eaa9f1 | |||
e62b947471 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
85
.github/workflows/CreateRelease.yml
vendored
Normal file
85
.github/workflows/CreateRelease.yml
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
name: Create Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "VERSION"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install pyinstaller openai
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$VERSION = (Get-Content -Path "./VERSION" -Raw).Trim()
|
||||
echo "VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8NoBOM -Append
|
||||
|
||||
- name: Run auto-py-to-exe
|
||||
run: |
|
||||
pyinstaller --noconfirm --onefile --console --name "ait-v${{ env.VERSION }}-winx64" --clean "./ait.py"
|
||||
|
||||
- name: Get previous release tag
|
||||
id: get_previous_release
|
||||
shell: pwsh
|
||||
run: |
|
||||
Write-Host "Fetching previous release tag..."
|
||||
$previous_tag = git describe --tags --abbrev=0 HEAD^ 2>$null
|
||||
if (-not $previous_tag) {
|
||||
Write-Host "No previous tag found, using initial commit."
|
||||
$previous_tag = git rev-list --max-parents=0 HEAD
|
||||
}
|
||||
Write-Host "Previous tag: $previous_tag"
|
||||
echo "PREVIOUS_TAG=$previous_tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Generate release notes
|
||||
id: generate_notes
|
||||
shell: pwsh
|
||||
run: |
|
||||
Write-Host "Generating release notes from $env:PREVIOUS_TAG to HEAD..."
|
||||
$repo_url = git config --get remote.origin.url
|
||||
$notes = git log "$env:PREVIOUS_TAG..HEAD" --pretty=format:"- [`%h`]($repo_url/commit/%H): %s"
|
||||
Write-Host "Release notes:"
|
||||
Write-Host "$notes"
|
||||
"### Changes in this release" | Out-File -FilePath release_notes.md -Encoding utf8
|
||||
$notes | Out-File -FilePath release_notes.md -Encoding utf8 -Append
|
||||
|
||||
- name: Create Tag
|
||||
id: create_tag
|
||||
shell: pwsh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git tag $env:VERSION
|
||||
git push origin $env:VERSION
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ env.VERSION }}
|
||||
name: Release ${{ env.VERSION }}
|
||||
body_path: release_notes.md
|
||||
files: |
|
||||
./dist/ait-v${{ env.VERSION }}-winx64.exe
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@ ait.*.config.json
|
||||
!ait.sample.config.json
|
||||
!ait.*.sample.config.json
|
||||
dist/
|
||||
*.spec
|
||||
build/
|
||||
|
@@ -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`.
|
||||
|
@@ -6,5 +6,5 @@
|
||||
"prompt": "Generate a concise commit message based on the provided Git diffs, including:\\n - A short and direct subject line (under 50 characters) summarizing the specific changes. No formatting should be used in the subject line.\\n - A brief bullet-point list of the exact modifications made, with basic Markdown formatting allowed in the body.\\n \\n Focus strictly on the changes themselves, avoiding any speculation about the reasons or potential impacts. Ensure that the message is informative enough to understand the changes without needing additional context.",
|
||||
"model": "gpt-4o",
|
||||
"max_tokens": 1000,
|
||||
"temperature": 0.7
|
||||
"temperature": 0.6
|
||||
}
|
@@ -3,8 +3,8 @@
|
||||
"diff_expression": "main...",
|
||||
"log_expression": "main...",
|
||||
"system_prompt": "**You are an automatic pull request message generator and an expert in this field!**",
|
||||
"prompt": "Generate a concise pull request message based on the provided Git diffs, including:\\n - A short and direct subject line (under 50 characters) summarizing the specific changes. No formatting should be used in the subject line.\\n - A brief bullet-point list of the exact modifications made, with basic Markdown formatting allowed in the body.\\n - A detailed description in Markdown format explaining the changes, their purpose, and any additional context that is relevant for the reviewers.\\n \\n Focus strictly on the changes themselves, avoiding any speculation about the reasons or potential impacts beyond the modifications. Ensure that the message is informative enough to understand the changes and their context for a comprehensive review.",
|
||||
"prompt": "Generate a concise pull request message based on the provided Git diffs, including:\\n - A short and direct subject line (under 50 characters) summarizing the specific changes. No formatting should be used in the subject line.\\n - A brief bullet-point list of the exact modifications made, with basic Markdown formatting allowed in the body.\\n - A detailed description in Markdown format explaining the changes, and any additional context that is relevant for the reviewers.\\n \\n Focus strictly on the changes themselves, avoiding any speculation about the reasons or potential impacts.\\n **Do not include any closing statements or generic sentences. End the message immediately after providing the necessary details.**",
|
||||
"model": "gpt-4o",
|
||||
"max_tokens": 1000,
|
||||
"temperature": 0.7
|
||||
"max_tokens": 2000,
|
||||
"temperature": 0.6
|
||||
}
|
27
ait.py
27
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
|
||||
@@ -146,4 +162,5 @@ if __name__ == "__main__":
|
||||
)
|
||||
|
||||
# Output the generated text
|
||||
print(generated_text)
|
||||
print("\n" + generated_text + "\n")
|
||||
|
||||
|
Reference in New Issue
Block a user