commit
This commit is contained in:
parent
98741aa013
commit
97542fc5d8
|
@ -1,3 +1,3 @@
|
|||
# BD-js
|
||||
|
||||
Just a git repo to keep my betterdiscord configs safe.
|
||||
Just a git repo to keep my betterdiscord configs safe
|
27
sync.py
27
sync.py
|
@ -5,20 +5,17 @@ def run_command(command):
|
|||
return result.stdout.strip()
|
||||
|
||||
def get_largest_diff_file():
|
||||
diff_files = run_command("git diff --name-only").splitlines()
|
||||
largest_file = None
|
||||
largest_size = 0
|
||||
|
||||
for file in diff_files:
|
||||
# Using 'git diff --numstat' to get the number of changes in each file
|
||||
diff_stats = run_command(f"git diff --numstat {file}").split()
|
||||
if diff_stats:
|
||||
# diff_stats[0] + diff_stats[1] gives the total changes for the file
|
||||
size = int(diff_stats[0]) + int(diff_stats[1])
|
||||
if size > largest_size:
|
||||
largest_size = size
|
||||
largest_file = file
|
||||
|
||||
diff_stats = run_command("git diff --numstat").splitlines()
|
||||
largest_diff = 0
|
||||
largest_file = ""
|
||||
for line in diff_stats:
|
||||
parts = line.split()
|
||||
if len(parts) >= 3:
|
||||
added, deleted, filename = parts[0], parts[1], parts[2]
|
||||
total_changes = int(added) + int(deleted)
|
||||
if total_changes > largest_diff:
|
||||
largest_diff = total_changes
|
||||
largest_file = filename
|
||||
return largest_file
|
||||
|
||||
def has_remote_changes():
|
||||
|
@ -38,7 +35,7 @@ def main():
|
|||
print("Adding and committing local changes...")
|
||||
run_command("git add .")
|
||||
largest_diff_file = get_largest_diff_file()
|
||||
commit_message = f'Updated {largest_diff_file}' if largest_diff_file else "Updated with changes"
|
||||
commit_message = f'Updated {largest_diff_file}' if largest_diff_file else "commit"
|
||||
run_command(f'git commit -S -m "{commit_message}"')
|
||||
run_command("git push")
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue