From 2eb4af77974109527e0315bb8d8b07c8d6933380 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 7 Mar 2024 11:47:57 -0500 Subject: [PATCH] git commiting --- CMakeLists.txt | 2 +- commit.py | 24 ++++++++++------ commit.py.save | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ commit.sh | 5 ---- 4 files changed, 91 insertions(+), 14 deletions(-) create mode 100755 commit.py.save delete mode 100644 commit.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b4434d..4ce8ef9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) include(cmake/color.cmake) -set(BLT_VERSION 0.13.6) +set(BLT_VERSION 0.13.8) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/commit.py b/commit.py index 2aa4c86..07c55fa 100755 --- a/commit.py +++ b/commit.py @@ -2,7 +2,16 @@ import subprocess -#repos = ["origin", "github", "tpgc"] +#--------------------------------------- +# CONFIG +#--------------------------------------- + +VERSION_BEGIN_STR = "set(BLT_VERSION " +VERSION_END_STR = ")" + +#--------------------------------------- +# DO NOT TOUCH +#--------------------------------------- type = input("What kind of commit is this ((M)ajor, (m)inor, (p)atch)? ") @@ -18,9 +27,8 @@ def write_cmake(cmake_text): cmake_file.close() def get_version(cmake_text): - find_text = "set(BLT_VERSION " - begin = cmake_text.find(find_text) + len(find_text) - end = cmake_text.find(")", begin) + begin = cmake_text.find(VERSION_BEGIN_STR) + len(VERSION_BEGIN_STR) + end = cmake_text.find(VERSION_END_STR, begin) return (cmake_text[begin:end], begin, end) def split_version(cmake_text): @@ -60,7 +68,7 @@ elif type.startswith('p') or type.startswith('P') or len(type) == 0: print("Selected patch") write_cmake(inc_patch(load_cmake())) -subprocess.call("./py_commit_helper.sh") -#subprocess.call("git", "add", "*") -#subprocess.call("git commit") -#exec("git remote | xargs -L1 git push --all") +#subprocess.call("./py_commit_helper.sh") +subprocess.call(["git", "add", "*"]) +subprocess.call(["git", "commit"]) +subprocess.call(["sh -e 'git remote | xargs -L1 git push --all'"]) diff --git a/commit.py.save b/commit.py.save new file mode 100755 index 0000000..3ecb2e0 --- /dev/null +++ b/commit.py.save @@ -0,0 +1,74 @@ +#!/usr/bin/python3 + +import subprocess + +#--------------------------------------- +# CONFIG +#--------------------------------------- + +VERSION_BEGIN_STR = "set(BLT_VERSION " +VERSION_END_STR = ")" + +#--------------------------------------- +# DO NOT TOUCH +#--------------------------------------- + +type = input("What kind of commit is this ((M)ajor, (m)inor, (p)atch)? ") + +def load_cmake(): + cmake_file = open("CMakeLists.txt", 'r') + cmake_text = cmake_file.read() + cmake_file.close() + return cmake_text + +def write_cmake(cmake_text): + cmake_file = open("CMakeLists.txt", 'w') + cmake_file.write(cmake_text) + cmake_file.close() + +def get_version(cmake_text): + begin = cmake_text.find(VERSION_BEGIN_STR) + len(find_text) + end = cmake_text.find(VERSION_END_STR, begin) + return (cmake_text[begin:end], begin, end) + +def split_version(cmake_text): + version, begin, end = get_version(cmake_text) + version_parts = version.split('.') + return (version_parts, begin, end) + +def recombine(cmake_text, version_parts, begin, end): + constructed_version = version_parts[0] + '.' + version_parts[1] + '.' + version_parts[2] + constructed_text_begin = cmake_text[0:begin] + constrcuted_text_end = cmake_text[end::] + return constructed_text_begin + constructed_version + constrcuted_text_end + + +def inc_major(cmake_text): + version_parts, begin, end = split_version(cmake_text) + version_parts[0] = str(int(version_parts[0]) + 1) + return recombine(cmake_text, version_parts, begin, end) + +def inc_minor(cmake_text): + version_parts, begin, end = split_version(cmake_text) + version_parts[1] = str(int(version_parts[1]) + 1) + return recombine(cmake_text, version_parts, begin, end) + +def inc_patch(cmake_text): + version_parts, begin, end = split_version(cmake_text) + version_parts[2] = str(int(version_parts[2]) + 1) + return recombine(cmake_text, version_parts, begin, end) + +if type.startswith('M'): + print("Selected major") + write_cmake(inc_major(load_cmake())) +elif type.startswith('m'): + print("Selected minor") + write_cmake(inc_minor(load_cmake())) +elif type.startswith('p') or type.startswith('P') or len(type) == 0: + print("Selected patch") + write_cmake(inc_patch(load_cmake())) + +#subprocess.call("./py_commit_helper.sh") +subprocess.call("git", "add", "*") +subprocess.call("git", "commit") +subprocess.call("sh -e 'git remote | xargs -L1 git push --all'") diff --git a/commit.sh b/commit.sh deleted file mode 100644 index 16242cc..0000000 --- a/commit.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -git add * -git commit -git push -u github main -git push -u tpgc main