-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstapush.sh
executable file
·31 lines (21 loc) · 937 Bytes
/
instapush.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# get the directory of the script and the current directory
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
current_dir=$(pwd)
# change to the current directory
cd "$current_dir"
# pull the main branch (and bypass the manual merge message)
git pull origin main --no-edit
# add all changes to the staging area
git add .
# get the summary and changes of the staged changes
git_diff_summary="$(git diff --staged --stat)"
git_diff_changes="$(git diff --staged --unified=0)"
# if not, prompt the user to create a commit message
prompt="Create a message for the following:\nSummary:\n$git_diff_summary\nChanges:\n$git_diff_changes"
# generate the commit message using a Python script
commit_msg=$(python "$script_dir/generate_commit_message.py" "$prompt")
# commit the changes with the generated commit message
git commit -am "$commit_msg"
# push the changes to the remote repository
git push