From 827f21e23868b9164e188225a2d84289f414a18f Mon Sep 17 00:00:00 2001 From: "Eshan Roy (Eshanized)" <148610067+eshanized@users.noreply.github.com> Date: Tue, 18 Jun 2024 03:47:47 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore(remove):=20puthon=20based?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commit.py | 108 ------------------------------------------------------ 1 file changed, 108 deletions(-) delete mode 100644 commit.py diff --git a/commit.py b/commit.py deleted file mode 100644 index 86c11d7..0000000 --- a/commit.py +++ /dev/null @@ -1,108 +0,0 @@ -# Author : Eshan Roy -# Author URL : https://eshanized.github.io - -# NOTE: Run at your own risk. - -import os -import subprocess - -def commit_with_conventional_message(message, branch): - # Check if the commit message is conventional - if not is_conventional(message): - print("Error: Commit message is not conventional") - return - - # Add all changes - subprocess.run(["git", "add", "."]) - - # Commit with the conventional message - subprocess.run(["git", "commit", "-m", message]) - - # Push to GitHub - subprocess.run(["git", "push", "origin", branch]) - -def pull_from_github(branch): - # Pull from GitHub - subprocess.run(["git", "pull", "origin", branch]) - -def is_conventional(message): - # Check if the commit message is conventional - conventional_types = [ - "build", - "chore", - "ci", - "docs", - "feat", - "fix", - "perf", - "refactor", - "revert", - "style", - "test", - ] - for type in conventional_types: - if message.startswith(f"{commit_emojis[type]} {type}:") or message.startswith(f"{commit_emojis[type]} {type}("): - return True - return False - -# Get the conventional commit message type from the user -print("Select a conventional commit message type:") -print("1. feat (new feature) ๐ŸŽ‰") -print("2. fix (bug fix) ๐Ÿ”ง") -print("3. perf (performance improvement) โšก๏ธ") -print("4. refactor (code refactoring) ๐Ÿ’ก") -print("5. style (code style change) ๐Ÿ’„") -print("6. test (new test) ๐Ÿงช") -print("7. docs (documentation change) ๐Ÿ“š") -print("8. build (build process change) ๐Ÿ—๏ธ") -print("9. chore (miscellaneous task) ๐Ÿงน") -print("10. revert (revert previous commit) ๐Ÿšจ") - -option = int(input("Enter the number of your chosen option: ")) - -commit_types = [ - "feat", - "fix", - "perf", - "refactor", - "style", - "test", - "docs", - "build", - "chore", - "revert" - ] -commit_type = commit_types[option - 1] - -commit_emojis = { - "feat": "๐ŸŽ‰", - "fix": "๐Ÿ”ง", - "perf": "โšก๏ธ", - "refactor": "๐Ÿ’ก", - "style": "๐Ÿ’„", - "test": "๐Ÿงช", - "docs": "๐Ÿ“š", - "build": "๐Ÿ—๏ธ", - "chore": "๐Ÿงน", - "revert": "๐Ÿšจ", - "ci": "๐Ÿค–" # added ci key -} - -# Get the scope and description from the user -scope = input("Enter the scope (optional): ") -description = input("Enter the description: ") - -# Get the branch name from the user -branch = "master" # or "main", "development" - -# Construct the conventional commit message -if scope: - message = f"{commit_emojis[commit_type]} {commit_type}({scope}): {description}" -else: - message = f"{commit_emojis[commit_type]} {commit_type}: {description}" - -# Commit with the conventional message -commit_with_conventional_message(message, branch) - -# Pull from GitHub -pull_from_github(branch) \ No newline at end of file