Skip to content

Instantly share code, notes, and snippets.

@dmgolembiowski
Forked from marskar/camp.py
Created April 5, 2023 19:07
Show Gist options
  • Save dmgolembiowski/7399e46c9f72d90cb6b8b00fa8b549c2 to your computer and use it in GitHub Desktop.
Save dmgolembiowski/7399e46c9f72d90cb6b8b00fa8b549c2 to your computer and use it in GitHub Desktop.
CAMP stands for git commit --add --message && git push
import git
repo = git.Repo()
changed_file_lists = [
[file.a_path
for file in repo.index.diff(None).iter_change_type(change_type)]
for change_type in ('D', 'M')
]
if any(changed_file_lists):
repo.git.add(changed_file_lists)
prefixes = "Deleted files:", "Modified files:"
deleted, modified = (
f"{prefix} {', '.join(changed_files)}. " if changed_files else ""
for prefix, changed_files in zip(prefixes, changed_file_lists)
)
print(repo.git.commit(changed_file_lists, message=deleted + modified),
repo.git.push())
else:
print("There are no deleted or modified files.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment