From 4eb67e2632946e9125c10a46ed64a8ac66306f0b Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 17:48:55 -0400 Subject: [PATCH 01/32] silly --- CMakeLists.txt | 2 +- lib/blt | 2 +- src/main.cpp | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 721f6a8..89b1de3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 0.0.15) +project(COSC-4P80-Assignment-1 VERSION 0.0.16) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/lib/blt b/lib/blt index 329eeb1..0d13e97 160000 --- a/lib/blt +++ b/lib/blt @@ -1 +1 @@ -Subproject commit 329eeb174bcb66f3403255d324c6c8451246a131 +Subproject commit 0d13e9738f6f666faec827940948337cef644aba diff --git a/src/main.cpp b/src/main.cpp index aa7e61e..5677efe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -156,6 +156,8 @@ int main() for (const auto& [index, value] : blt::enumerate(part_c_2_inputs).skip(2).take(3)) BLT_TRACE_STREAM << index << " : " << value.vec_from_column_row() << '\n'; +// BLT_TRACE("%s", blt::type_string::type>().c_str()); + // part_a(); // part_b(); From 26d32972f182c28f5a8a42dcc41fa0ca9adf6fc4 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:15:09 -0400 Subject: [PATCH 02/32] test --- CMakeLists.txt | 2 +- commit.py | 228 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 213 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89b1de3..bfc01cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 0.0.16) +project(COSC-4P80-Assignment-1 VERSION 0.0.17) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index b39f82d..1b73249 100755 --- a/commit.py +++ b/commit.py @@ -1,6 +1,13 @@ #!/usr/bin/python3 import subprocess +import argparse +import sys +import os +import itertools +import requests +import json +from pathlib import Path #--------------------------------------- # CONFIG @@ -8,12 +15,105 @@ import subprocess VERSION_BEGIN_STR = " VERSION " VERSION_END_STR = ")" -PATCH_LIMIT = 100000 #--------------------------------------- # DO NOT TOUCH #--------------------------------------- +USER_HOME = Path.home() +ENVIRONMENT_DATA_LOCATION = USER_HOME / ".brett_scripts.env" + +if sys.platform.startswith("win"): + CONFIG_FILE_DIRECTORY = Path(os.getenv('APPDATA') + "\BLT") + CONFIG_FILE_LOCATION = Path(CONFIG_FILE_DIRECTORY + "\commit_config.env") +else: + XDG_CONFIG_HOME = Path(os.environ.get('XDG_CONFIG_HOME')) + if len(str(XDG_CONFIG_HOME)) == 0: + XDG_CONFIG_HOME = USER_HOME + CONFIG_FILE_DIRECTORY = XDG_CONFIG_HOME / "blt" + CONFIG_FILE_LOCATION = CONFIG_FILE_DIRECTORY / "commit_config.env" + +class Config: + def __init__(self): + # Inline with semantic versioning it doesn't make sense to branch / release on minor + self.branch_on_major = True + self.branch_on_minor = False + self.release_on_major = True + self.release_on_minor = False + self.main_branch = "main" + self.patch_limit = -1 + + def from_file(file): + values = {} + if (not os.path.exists(file)): + return Config() + + with open(file, "rt") as f: + for line in f: + if line.startswith("export"): + content = line.split("=") + for idx, c in enumerate(content): + content[idx] = c.replace("export", "").strip() + values[content[0]] = content[1].replace("\"", "").replace("'", "") + config = Config() + config.branch_on_major = values["branch_on_major"].lower() == "true" + config.release_on_major = values["release_on_major"].lower() == "true" + config.main_branch = values["main_branch"] + config.patch_limit = int(values["patch_limit"]) + + return config; + + def save_to_file(self, file): + dir_index = str(file).rfind("/") + dir = str(file)[:dir_index] + if not os.path.exists(dir): + print(f"Creating config directory {dir}") + os.makedirs(dir) + with open(file, 'w') as f: + f.write("export branch_on_major=" + str(self.branch_on_major) + "\n") + f.write("export release_on_major=" + str(self.release_on_major) + "\n") + f.write('export main_branch="' + self.main_branch + '"' + "\n") + f.write("export patch_limit=" + str(self.patch_limit) + "\n") + + +class EnvData: + def __init__(self, github_username = '', github_token = ''): + self.github_token = github_token + self.github_username = github_username + + def get_env_from_file(file): + f = open(file, "rt") + values = {} + for line in f: + if line.startswith("export"): + content = line.split("=") + for idx, c in enumerate(content): + content[idx] = c.replace("export", "").strip() + values[content[0]] = content[1].replace("\"", "").replace("'", "") + try: + github_token = values["github_token"] + except Exception: + print("Failed to parse github token!") + try: + github_username = values["github_username"] + except: + print("Failed to parse github username! Assuming you are me!") + github_username = "Tri11Paragon" + return EnvData(github_username=github_username, github_token=github_token) + +def open_process(command, print_out = True): + process = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + stdout, stderr = process.communicate() + exit_code = process.wait() + str_out = stdout.decode('utf8') + str_err = stderr.decode('utf8') + if print_out and len(str_out) > 0: + print(str_out, end='') + if print_out and len(str_err) > 0: + print(str_err, end='') + #print(stdout, stderr, exit_code) + return (stdout, stderr, exit_code) + def load_cmake(): cmake_file = open("CMakeLists.txt", 'r') cmake_text = cmake_file.read() @@ -38,8 +138,8 @@ def split_version(cmake_text): 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 + constructed_text_end = cmake_text[end::] + return constructed_text_begin + constructed_version + constructed_text_end def inc_major(cmake_text): @@ -55,32 +155,128 @@ def inc_minor(cmake_text): version_parts[2] = '0' return recombine(cmake_text, version_parts, begin, end) -def inc_patch(cmake_text): +def inc_patch(config: Config, cmake_text): version_parts, begin, end = split_version(cmake_text) - if int(version_parts[2]) + 1 >= PATCH_LIMIT: + if config.patch_limit > 0 and int(version_parts[2]) + 1 >= config.patch_limit: return inc_minor(cmake_text) version_parts[2] = str(int(version_parts[2]) + 1) return recombine(cmake_text, version_parts, begin, end) -cmake_text = load_cmake() -cmake_version = get_version(cmake_text)[0] -print(f"Current Version: {cmake_version}") +def make_branch(config: Config, name): + print(f"Making new branch {name}") + subprocess.call(["git", "branch", "-b", name]) + subprocess.call(["git", "checkout", name]) + subprocess.call(["git", "merge", config.main_branch]) + subprocess.call(["git", "checkout", config.main_branch]) -try: - type = input("What kind of commit is this ((M)ajor, (m)inor, (p)atch)? ") +def make_release(env: EnvData, name): + print(f"Making new release {name}") + repos_v = open_process(["git", "remote", "-v"])[0].splitlines() + urls = [] + for line in repos_v: + origin = itertools.takewhile(lambda c: not c.isspace(), line) + print(f"Origin: {origin}") + urls.append(open_process(["git", "remote", "get-url", origin])[0]) + urls = set(urls) + print(urls) + data = { + 'tag_name': name, + 'name': name, + 'body': "Automated Release", + 'draft': False, + 'prerelease': False + } + headers = { + 'Authorization': f'token {env.github_token}', + 'Accept': 'application/vnd.github.v3+json' + } + for url in urls: + response = requests.post(url, headers=headers, data=json.dumps(data)) + if response.status_code == 201: + print('Release created successfully!') + release_data = response.json() + print(f"Release URL: {release_data['html_url']}") + else: + print(f"Failed to create release: {response.status_code}") + print(response.json()) - if type.startswith('M'): + +def main(): + parser = argparse.ArgumentParser( + prog="Commit Helper", + description="Help you make pretty commits :3") + + parser.add_argument("action", nargs='?', default=None) + parser.add_argument("-p", "--patch", action='store_true', default=False, required=False) + parser.add_argument("-m", "--minor", action='store_true', default=False, required=False) + parser.add_argument("-M", "--major", action='store_true', default=False, required=False) + parser.add_argument('-e', "--env", help="environment file", required=False) + parser.add_argument('-c', "--config", help="config file", required=False) + parser.add_argument("--create_default_config", action="store_true", default=False, required=False) + + args = parser.parse_args() + + if args.env is not None: + env = EnvData.get_env_from_file(args.e) + else: + env = EnvData.get_env_from_file(ENVIRONMENT_DATA_LOCATION) + + if args.config is not None: + config = Config.from_file(args.config) + else: + config = Config.from_file(CONFIG_FILE_LOCATION) + + if args.create_default_config: + config.save_to_file(args.config if args.config is not None else CONFIG_FILE_LOCATION) + + cmake_text = load_cmake() + cmake_version = get_version(cmake_text)[0] + print(f"Current Version: {cmake_version}") + + if not (args.patch or args.minor or args.major): + try: + if args.action is not None: + type = args.action + else: + type = input("What kind of commit is this ((M)ajor, (m)inor, (p)atch)? ") + + if type.startswith('M'): + args.major = True + elif type.startswith('m'): + args.minor = True + elif type.startswith('p') or type.startswith('P') or len(type) == 0: + args.patch = True + except KeyboardInterrupt: + print("\nCancelling!") + return + + if args.major: print("Selected major") write_cmake(inc_major(cmake_text)) - elif type.startswith('m'): + elif args.minor: print("Selected minor") write_cmake(inc_minor(cmake_text)) - elif type.startswith('p') or type.startswith('P') or len(type) == 0: + elif args.patch: print("Selected patch") - write_cmake(inc_patch(cmake_text)) + write_cmake(inc_patch(config, cmake_text)) + subprocess.call(["git", "add", "*"]) subprocess.call(["git", "commit"]) + + if args.major: + version_parts = split_version(cmake_text)[0] + if config.branch_on_major: + make_branch(config, "v" + str(version_parts[0])) + if config.branch_on_minor: + make_branch(config, "v" + str(version_parts[0]) + "." + str(version_parts[1])) + if config.release_on_major: + make_release(env, "v" + str(version_parts[0])) + if config.release_on_minor: + make_release(env, "v" + str(version_parts[0]) + "." + str(version_parts[1])) + + subprocess.call(["sh", "-c", "git remote | xargs -L1 git push --all"]) -except KeyboardInterrupt: - print("\nCancelling!") + +if __name__ == "__main__": + main() From 32130f51aafe7bfa1fda4cacbb96625ab43e3b0b Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:15:21 -0400 Subject: [PATCH 03/32] testing release/branch making --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfc01cf..366a603 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 0.0.17) +project(COSC-4P80-Assignment-1 VERSION 1.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From 04241268f50eb5f5db5e839dd3b3e1d3510ea00e Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:18:40 -0400 Subject: [PATCH 04/32] testing branch / release --- CMakeLists.txt | 2 +- commit.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 366a603..62efb0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 1.0.0) +project(COSC-4P80-Assignment-1 VERSION 1.1.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 1b73249..102cade 100755 --- a/commit.py +++ b/commit.py @@ -164,8 +164,7 @@ def inc_patch(config: Config, cmake_text): def make_branch(config: Config, name): print(f"Making new branch {name}") - subprocess.call(["git", "branch", "-b", name]) - subprocess.call(["git", "checkout", name]) + subprocess.call(["git", "checkout", "-b", name]) subprocess.call(["git", "merge", config.main_branch]) subprocess.call(["git", "checkout", config.main_branch]) @@ -174,7 +173,7 @@ def make_release(env: EnvData, name): repos_v = open_process(["git", "remote", "-v"])[0].splitlines() urls = [] for line in repos_v: - origin = itertools.takewhile(lambda c: not c.isspace(), line) + origin = ''.join(itertools.takewhile(lambda c: not c.isspace(), line)) print(f"Origin: {origin}") urls.append(open_process(["git", "remote", "get-url", origin])[0]) urls = set(urls) From 15c8f2698d4855a729950823642b3e6465ae328f Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:18:58 -0400 Subject: [PATCH 05/32] testing branch / release --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62efb0b..cb196c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 1.1.0) +project(COSC-4P80-Assignment-1 VERSION 2.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From 33e8548de1662ef455e8a174d4eba952ec93a3d3 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:20:03 -0400 Subject: [PATCH 06/32] testing branch / release --- CMakeLists.txt | 2 +- commit.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb196c9..0c56c41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 2.0.0) +project(COSC-4P80-Assignment-1 VERSION 3.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 102cade..bff50e5 100755 --- a/commit.py +++ b/commit.py @@ -173,7 +173,7 @@ def make_release(env: EnvData, name): repos_v = open_process(["git", "remote", "-v"])[0].splitlines() urls = [] for line in repos_v: - origin = ''.join(itertools.takewhile(lambda c: not c.isspace(), line)) + origin = ''.join(itertools.takewhile(lambda c: not str(c).isspace(), line)) print(f"Origin: {origin}") urls.append(open_process(["git", "remote", "get-url", origin])[0]) urls = set(urls) From 664376d9b14a5aa53961e3f9b27521d1f62c6327 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:21:39 -0400 Subject: [PATCH 07/32] testing make release/branch --- CMakeLists.txt | 2 +- commit.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c56c41..e24e079 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 3.0.0) +project(COSC-4P80-Assignment-1 VERSION 4.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index bff50e5..5ded88d 100755 --- a/commit.py +++ b/commit.py @@ -173,7 +173,7 @@ def make_release(env: EnvData, name): repos_v = open_process(["git", "remote", "-v"])[0].splitlines() urls = [] for line in repos_v: - origin = ''.join(itertools.takewhile(lambda c: not str(c).isspace(), line)) + origin = ''.join(itertools.takewhile(not str.isspace, line)) print(f"Origin: {origin}") urls.append(open_process(["git", "remote", "get-url", origin])[0]) urls = set(urls) From a98755bd6cc6db19376fa29b8511b315bcc8aa3a Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:22:39 -0400 Subject: [PATCH 08/32] testing release / branch --- CMakeLists.txt | 2 +- commit.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e24e079..4fc0602 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 4.0.0) +project(COSC-4P80-Assignment-1 VERSION 5.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 5ded88d..d33d7d7 100755 --- a/commit.py +++ b/commit.py @@ -173,7 +173,7 @@ def make_release(env: EnvData, name): repos_v = open_process(["git", "remote", "-v"])[0].splitlines() urls = [] for line in repos_v: - origin = ''.join(itertools.takewhile(not str.isspace, line)) + origin = ''.join(itertools.takewhile(str.isalpha, line)) print(f"Origin: {origin}") urls.append(open_process(["git", "remote", "get-url", origin])[0]) urls = set(urls) @@ -263,6 +263,7 @@ def main(): subprocess.call(["git", "add", "*"]) subprocess.call(["git", "commit"]) + cmake_text = load_cmake() if args.major: version_parts = split_version(cmake_text)[0] if config.branch_on_major: From 978ceeb13b28b7ba247f152937638500f19a1373 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:23:50 -0400 Subject: [PATCH 09/32] test --- CMakeLists.txt | 2 +- commit.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fc0602..005dbab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 5.0.0) +project(COSC-4P80-Assignment-1 VERSION 6.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index d33d7d7..167516d 100755 --- a/commit.py +++ b/commit.py @@ -171,6 +171,8 @@ def make_branch(config: Config, name): def make_release(env: EnvData, name): print(f"Making new release {name}") repos_v = open_process(["git", "remote", "-v"])[0].splitlines() + print(repos_v) + exit(0) urls = [] for line in repos_v: origin = ''.join(itertools.takewhile(str.isalpha, line)) From 23a4c5d6c954cd3ad4a0656e8f435126fa273cc1 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:24:40 -0400 Subject: [PATCH 10/32] test --- CMakeLists.txt | 2 +- commit.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 005dbab..9388df4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 6.0.0) +project(COSC-4P80-Assignment-1 VERSION 7.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 167516d..304236d 100755 --- a/commit.py +++ b/commit.py @@ -171,11 +171,10 @@ def make_branch(config: Config, name): def make_release(env: EnvData, name): print(f"Making new release {name}") repos_v = open_process(["git", "remote", "-v"])[0].splitlines() - print(repos_v) - exit(0) urls = [] for line in repos_v: - origin = ''.join(itertools.takewhile(str.isalpha, line)) + print(line.decode('utf8')) + origin = ''.join(itertools.takewhile(str.isalpha, line.decode('utf8'))) print(f"Origin: {origin}") urls.append(open_process(["git", "remote", "get-url", origin])[0]) urls = set(urls) From 95bac2d1f88a7d59b329954bec18ad17eee32263 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:25:39 -0400 Subject: [PATCH 11/32] test --- CMakeLists.txt | 2 +- commit.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9388df4..eb67c6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 7.0.0) +project(COSC-4P80-Assignment-1 VERSION 8.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 304236d..19f2b90 100755 --- a/commit.py +++ b/commit.py @@ -173,12 +173,11 @@ def make_release(env: EnvData, name): repos_v = open_process(["git", "remote", "-v"])[0].splitlines() urls = [] for line in repos_v: - print(line.decode('utf8')) origin = ''.join(itertools.takewhile(str.isalpha, line.decode('utf8'))) print(f"Origin: {origin}") - urls.append(open_process(["git", "remote", "get-url", origin])[0]) + urls.append(open_process(["git", "remote", "get-url", origin])[0].decode('utf8')) urls = set(urls) - print(urls) + print(f"Urls: {urls}") data = { 'tag_name': name, 'name': name, From b36781464a65068ea2993c773223e2c34f632f29 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:26:05 -0400 Subject: [PATCH 12/32] test --- CMakeLists.txt | 2 +- commit.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb67c6e..1425e92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 8.0.0) +project(COSC-4P80-Assignment-1 VERSION 9.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 19f2b90..6db01d5 100755 --- a/commit.py +++ b/commit.py @@ -175,7 +175,7 @@ def make_release(env: EnvData, name): for line in repos_v: origin = ''.join(itertools.takewhile(str.isalpha, line.decode('utf8'))) print(f"Origin: {origin}") - urls.append(open_process(["git", "remote", "get-url", origin])[0].decode('utf8')) + urls.append(open_process(["git", "remote", "get-url", origin])[0].decode('utf8').replace("\n", "")) urls = set(urls) print(f"Urls: {urls}") data = { From e273715b65d7979b1d268e1ad8bd1c39733317e5 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:26:53 -0400 Subject: [PATCH 13/32] test --- CMakeLists.txt | 2 +- commit.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1425e92..ca45fe4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 9.0.0) +project(COSC-4P80-Assignment-1 VERSION 10.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 6db01d5..e95f9da 100755 --- a/commit.py +++ b/commit.py @@ -175,7 +175,7 @@ def make_release(env: EnvData, name): for line in repos_v: origin = ''.join(itertools.takewhile(str.isalpha, line.decode('utf8'))) print(f"Origin: {origin}") - urls.append(open_process(["git", "remote", "get-url", origin])[0].decode('utf8').replace("\n", "")) + urls.append(open_process(["git", "remote", "get-url", origin])[0].decode('utf8').replace("\n", "") + "/releases") urls = set(urls) print(f"Urls: {urls}") data = { From 6e2d125d552d0e33fc8d2e3ff79baf2ace16d562 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:31:33 -0400 Subject: [PATCH 14/32] test --- CMakeLists.txt | 2 +- commit.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca45fe4..f8f964f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 10.0.0) +project(COSC-4P80-Assignment-1 VERSION 11.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index e95f9da..a938d6c 100755 --- a/commit.py +++ b/commit.py @@ -174,8 +174,7 @@ def make_release(env: EnvData, name): urls = [] for line in repos_v: origin = ''.join(itertools.takewhile(str.isalpha, line.decode('utf8'))) - print(f"Origin: {origin}") - urls.append(open_process(["git", "remote", "get-url", origin])[0].decode('utf8').replace("\n", "") + "/releases") + urls.append("https://api.github.com/repos/" + open_process(["git", "remote", "get-url", origin])[0].decode('utf8').replace("\n", "").replace("https://github.com/") + "releases") urls = set(urls) print(f"Urls: {urls}") data = { From 3641bf1ec4e46d0c092b98d72589c24edaf644e8 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:32:30 -0400 Subject: [PATCH 15/32] test --- CMakeLists.txt | 2 +- commit.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8f964f..eeda7b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 11.0.0) +project(COSC-4P80-Assignment-1 VERSION 12.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index a938d6c..5abacd1 100755 --- a/commit.py +++ b/commit.py @@ -174,7 +174,7 @@ def make_release(env: EnvData, name): urls = [] for line in repos_v: origin = ''.join(itertools.takewhile(str.isalpha, line.decode('utf8'))) - urls.append("https://api.github.com/repos/" + open_process(["git", "remote", "get-url", origin])[0].decode('utf8').replace("\n", "").replace("https://github.com/") + "releases") + urls.append("https://api.github.com/repos/" + open_process(["git", "remote", "get-url", origin])[0].decode('utf8').replace("\n", "").replace("https://github.com/", "") + "releases") urls = set(urls) print(f"Urls: {urls}") data = { From 1d58ab74c6212e33776f28046cf15de4e65e118b Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:48:23 -0400 Subject: [PATCH 16/32] test --- CMakeLists.txt | 2 +- commit.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeda7b9..9d6112f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 12.0.0) +project(COSC-4P80-Assignment-1 VERSION 13.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 5abacd1..5e7c282 100755 --- a/commit.py +++ b/commit.py @@ -174,7 +174,7 @@ def make_release(env: EnvData, name): urls = [] for line in repos_v: origin = ''.join(itertools.takewhile(str.isalpha, line.decode('utf8'))) - urls.append("https://api.github.com/repos/" + open_process(["git", "remote", "get-url", origin])[0].decode('utf8').replace("\n", "").replace("https://github.com/", "") + "releases") + urls.append("https://api.github.com/repos/" + open_process(["git", "remote", "get-url", origin], False)[0].decode('utf8').replace("\n", "").replace("https://github.com/", "") + "/releases") urls = set(urls) print(f"Urls: {urls}") data = { @@ -185,8 +185,9 @@ def make_release(env: EnvData, name): 'prerelease': False } headers = { - 'Authorization': f'token {env.github_token}', - 'Accept': 'application/vnd.github.v3+json' + 'Authorization': f'Bearer {env.github_token}', + 'Accept': 'application/vnd.github+json', + 'X-GitHub-Api-Version': '2022-11-28' } for url in urls: response = requests.post(url, headers=headers, data=json.dumps(data)) From 27c85cc852fca937086b82328120319d6fbef501 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:52:09 -0400 Subject: [PATCH 17/32] testing minor release and branch --- CMakeLists.txt | 2 +- commit.py | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d6112f..539a17c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.0.0) +project(COSC-4P80-Assignment-1 VERSION 13.1.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 5e7c282..3dfbcbb 100755 --- a/commit.py +++ b/commit.py @@ -56,10 +56,15 @@ class Config: content[idx] = c.replace("export", "").strip() values[content[0]] = content[1].replace("\"", "").replace("'", "") config = Config() - config.branch_on_major = values["branch_on_major"].lower() == "true" - config.release_on_major = values["release_on_major"].lower() == "true" - config.main_branch = values["main_branch"] - config.patch_limit = int(values["patch_limit"]) + try: + config.branch_on_major = values["branch_on_major"].lower() == "true" + config.branch_on_minor = values["branch_on_minor"].lower() == "true" + config.release_on_major = values["release_on_major"].lower() == "true" + config.release_on_minor = values["release_on_minor"].lower() == "true" + config.main_branch = values["main_branch"] + config.patch_limit = int(values["patch_limit"]) + except: + return config return config; @@ -71,7 +76,9 @@ class Config: os.makedirs(dir) with open(file, 'w') as f: f.write("export branch_on_major=" + str(self.branch_on_major) + "\n") + f.write("export branch_on_minor=" + str(self.branch_on_minor) + "\n") f.write("export release_on_major=" + str(self.release_on_major) + "\n") + f.write("export release_on_minor=" + str(self.release_on_minor) + "\n") f.write('export main_branch="' + self.main_branch + '"' + "\n") f.write("export patch_limit=" + str(self.patch_limit) + "\n") @@ -176,11 +183,10 @@ def make_release(env: EnvData, name): origin = ''.join(itertools.takewhile(str.isalpha, line.decode('utf8'))) urls.append("https://api.github.com/repos/" + open_process(["git", "remote", "get-url", origin], False)[0].decode('utf8').replace("\n", "").replace("https://github.com/", "") + "/releases") urls = set(urls) - print(f"Urls: {urls}") data = { 'tag_name': name, 'name': name, - 'body': "Automated Release", + 'body': "Automated Release '" + name + "'", 'draft': False, 'prerelease': False } @@ -270,13 +276,14 @@ def main(): make_branch(config, "v" + str(version_parts[0])) if config.branch_on_minor: make_branch(config, "v" + str(version_parts[0]) + "." + str(version_parts[1])) + + subprocess.call(["sh", "-c", "git remote | xargs -L1 git push --all"]) + + if args.major: if config.release_on_major: make_release(env, "v" + str(version_parts[0])) if config.release_on_minor: make_release(env, "v" + str(version_parts[0]) + "." + str(version_parts[1])) - - - subprocess.call(["sh", "-c", "git remote | xargs -L1 git push --all"]) if __name__ == "__main__": main() From f7c99ff088d2d6cd33e411dede138bdfacd49a1c Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:53:00 -0400 Subject: [PATCH 18/32] test minor --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 539a17c..ad24e24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.1.0) +project(COSC-4P80-Assignment-1 VERSION 13.2.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From 48dc7fa38cf96813321dba7fc5b9fc3ce78d263f Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:53:12 -0400 Subject: [PATCH 19/32] test minor --- CMakeLists.txt | 2 +- commit.py | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad24e24..7ef1229 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.2.0) +project(COSC-4P80-Assignment-1 VERSION 13.3.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 3dfbcbb..7948555 100755 --- a/commit.py +++ b/commit.py @@ -56,15 +56,12 @@ class Config: content[idx] = c.replace("export", "").strip() values[content[0]] = content[1].replace("\"", "").replace("'", "") config = Config() - try: - config.branch_on_major = values["branch_on_major"].lower() == "true" - config.branch_on_minor = values["branch_on_minor"].lower() == "true" - config.release_on_major = values["release_on_major"].lower() == "true" - config.release_on_minor = values["release_on_minor"].lower() == "true" - config.main_branch = values["main_branch"] - config.patch_limit = int(values["patch_limit"]) - except: - return config + config.branch_on_major = values["branch_on_major"].lower() == "true" + config.branch_on_minor = values["branch_on_minor"].lower() == "true" + config.release_on_major = values["release_on_major"].lower() == "true" + config.release_on_minor = values["release_on_minor"].lower() == "true" + config.main_branch = values["main_branch"] + config.patch_limit = int(values["patch_limit"]) return config; From 60258b0ba6b4be3064af664d439a28d3816005cd Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 26 Sep 2024 20:55:10 -0400 Subject: [PATCH 20/32] test minor --- CMakeLists.txt | 2 +- commit.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ef1229..8a23858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.3.0) +project(COSC-4P80-Assignment-1 VERSION 13.4.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 7948555..237a3e1 100755 --- a/commit.py +++ b/commit.py @@ -212,8 +212,8 @@ def main(): parser.add_argument("-p", "--patch", action='store_true', default=False, required=False) parser.add_argument("-m", "--minor", action='store_true', default=False, required=False) parser.add_argument("-M", "--major", action='store_true', default=False, required=False) - parser.add_argument('-e', "--env", help="environment file", required=False) - parser.add_argument('-c', "--config", help="config file", required=False) + parser.add_argument('-e', "--env", help="environment file", required=False, default=None) + parser.add_argument('-c', "--config", help="config file", required=False, default=None) parser.add_argument("--create_default_config", action="store_true", default=False, required=False) args = parser.parse_args() @@ -267,10 +267,11 @@ def main(): subprocess.call(["git", "commit"]) cmake_text = load_cmake() + version_parts = split_version(cmake_text)[0] if args.major: - version_parts = split_version(cmake_text)[0] if config.branch_on_major: make_branch(config, "v" + str(version_parts[0])) + if args.minor: if config.branch_on_minor: make_branch(config, "v" + str(version_parts[0]) + "." + str(version_parts[1])) @@ -279,6 +280,7 @@ def main(): if args.major: if config.release_on_major: make_release(env, "v" + str(version_parts[0])) + if args.minor: if config.release_on_minor: make_release(env, "v" + str(version_parts[0]) + "." + str(version_parts[1])) From ee4918ca36eac9b5e95097fe84c6de0cf5721608 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:16:40 -0400 Subject: [PATCH 21/32] testing branch release on minor --- CMakeLists.txt | 2 +- commit.py | 77 +++++++++++++++++++++++++------------------------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a23858..5a4ac0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.4.0) +project(COSC-4P80-Assignment-1 VERSION 13.5.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index 237a3e1..fda7d1b 100755 --- a/commit.py +++ b/commit.py @@ -24,14 +24,19 @@ USER_HOME = Path.home() ENVIRONMENT_DATA_LOCATION = USER_HOME / ".brett_scripts.env" if sys.platform.startswith("win"): - CONFIG_FILE_DIRECTORY = Path(os.getenv('APPDATA') + "\BLT") - CONFIG_FILE_LOCATION = Path(CONFIG_FILE_DIRECTORY + "\commit_config.env") + CONFIG_FILE_DIRECTORY = Path(os.getenv('APPDATA') + "\blt") + CONFIG_FILE_LOCATION = Path(CONFIG_FILE_DIRECTORY + "\commit_config.json") else: - XDG_CONFIG_HOME = Path(os.environ.get('XDG_CONFIG_HOME')) + XDG_CONFIG_HOME = os.environ.get('XDG_CONFIG_HOME') + if XDG_CONFIG_HOME is None: + XDG_CONFIG_HOME = USER_HOME / ".config" + else: + XDG_CONFIG_HOME = Path(XDG_CONFIG_HOME) + if len(str(XDG_CONFIG_HOME)) == 0: XDG_CONFIG_HOME = USER_HOME CONFIG_FILE_DIRECTORY = XDG_CONFIG_HOME / "blt" - CONFIG_FILE_LOCATION = CONFIG_FILE_DIRECTORY / "commit_config.env" + CONFIG_FILE_LOCATION = CONFIG_FILE_DIRECTORY / "commit_config.json" class Config: def __init__(self): @@ -39,31 +44,30 @@ class Config: self.branch_on_major = True self.branch_on_minor = False self.release_on_major = True - self.release_on_minor = False + self.release_on_minor = True self.main_branch = "main" self.patch_limit = -1 + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) + + def fromJSON(file): + with open(file, "r") as f: + j = json.load(f) + obj = Config() + [setattr(obj, key, val) for key, val in j.items() if hasattr(obj, key)] + return obj + def from_file(file): values = {} if (not os.path.exists(file)): return Config() - with open(file, "rt") as f: - for line in f: - if line.startswith("export"): - content = line.split("=") - for idx, c in enumerate(content): - content[idx] = c.replace("export", "").strip() - values[content[0]] = content[1].replace("\"", "").replace("'", "") - config = Config() - config.branch_on_major = values["branch_on_major"].lower() == "true" - config.branch_on_minor = values["branch_on_minor"].lower() == "true" - config.release_on_major = values["release_on_major"].lower() == "true" - config.release_on_minor = values["release_on_minor"].lower() == "true" - config.main_branch = values["main_branch"] - config.patch_limit = int(values["patch_limit"]) - - return config; + with open(file, "r") as f: + j = json.load(f) + obj = Config() + [setattr(obj, key, val) for key, val in j.items() if hasattr(obj, key)] + return obj def save_to_file(self, file): dir_index = str(file).rfind("/") @@ -71,13 +75,8 @@ class Config: if not os.path.exists(dir): print(f"Creating config directory {dir}") os.makedirs(dir) - with open(file, 'w') as f: - f.write("export branch_on_major=" + str(self.branch_on_major) + "\n") - f.write("export branch_on_minor=" + str(self.branch_on_minor) + "\n") - f.write("export release_on_major=" + str(self.release_on_major) + "\n") - f.write("export release_on_minor=" + str(self.release_on_minor) + "\n") - f.write('export main_branch="' + self.main_branch + '"' + "\n") - f.write("export patch_limit=" + str(self.patch_limit) + "\n") + with open(file, "w") as f: + json.dump(self, f, default=lambda o: o.__dict__, sort_keys=True, indent=4) class EnvData: @@ -145,7 +144,6 @@ def recombine(cmake_text, version_parts, begin, end): constructed_text_end = cmake_text[end::] return constructed_text_begin + constructed_version + constructed_text_end - def inc_major(cmake_text): version_parts, begin, end = split_version(cmake_text) version_parts[0] = str(int(version_parts[0]) + 1) @@ -214,10 +212,17 @@ def main(): parser.add_argument("-M", "--major", action='store_true', default=False, required=False) parser.add_argument('-e', "--env", help="environment file", required=False, default=None) parser.add_argument('-c', "--config", help="config file", required=False, default=None) - parser.add_argument("--create_default_config", action="store_true", default=False, required=False) + parser.add_argument("--create-default-config", action="store_true", default=False, required=False) + parser.add_argument("--no-release", action="store_true", default=False, required=False) + parser.add_argument("--no-branch", action="store_true", default=False, required=False) args = parser.parse_args() + if args.create_default_config: + config = Config() + config.save_to_file(args.config if args.config is not None else CONFIG_FILE_LOCATION) + return + if args.env is not None: env = EnvData.get_env_from_file(args.e) else: @@ -227,9 +232,6 @@ def main(): config = Config.from_file(args.config) else: config = Config.from_file(CONFIG_FILE_LOCATION) - - if args.create_default_config: - config.save_to_file(args.config if args.config is not None else CONFIG_FILE_LOCATION) cmake_text = load_cmake() cmake_version = get_version(cmake_text)[0] @@ -262,25 +264,24 @@ def main(): print("Selected patch") write_cmake(inc_patch(config, cmake_text)) - subprocess.call(["git", "add", "*"]) subprocess.call(["git", "commit"]) cmake_text = load_cmake() version_parts = split_version(cmake_text)[0] - if args.major: + if not args.no_branch and args.major: if config.branch_on_major: make_branch(config, "v" + str(version_parts[0])) - if args.minor: + if not args.no_branch and args.minor: if config.branch_on_minor: make_branch(config, "v" + str(version_parts[0]) + "." + str(version_parts[1])) subprocess.call(["sh", "-c", "git remote | xargs -L1 git push --all"]) - if args.major: + if not args.no_release and args.major: if config.release_on_major: make_release(env, "v" + str(version_parts[0])) - if args.minor: + if not args.no_release and args.minor: if config.release_on_minor: make_release(env, "v" + str(version_parts[0]) + "." + str(version_parts[1])) From 7e50ac4f063e169a6d5f59e9da04a5757152a688 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:16:59 -0400 Subject: [PATCH 22/32] testing disable release --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a4ac0d..c2c7a4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.5.0) +project(COSC-4P80-Assignment-1 VERSION 13.6.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From a069e33c590cc76660904c26b588855f64241e0b Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:50:41 -0400 Subject: [PATCH 23/32] testing patch merge to branch --- CMakeLists.txt | 2 +- commit.py | 43 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2c7a4e..42c9da5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.6.0) +project(COSC-4P80-Assignment-1 VERSION 13.6.1) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index fda7d1b..54bb00c 100755 --- a/commit.py +++ b/commit.py @@ -56,6 +56,8 @@ class Config: j = json.load(f) obj = Config() [setattr(obj, key, val) for key, val in j.items() if hasattr(obj, key)] + if obj.branch_on_minor: + obj.branch_on_major = True return obj def from_file(file): @@ -169,6 +171,12 @@ def make_branch(config: Config, name): subprocess.call(["git", "checkout", "-b", name]) subprocess.call(["git", "merge", config.main_branch]) subprocess.call(["git", "checkout", config.main_branch]) + +def sync_branch(config: Config, version_parts, args): + if config.branch_on_major: + # Branch will be created. + if args.minor: + return; def make_release(env: EnvData, name): print(f"Making new release {name}") @@ -269,20 +277,39 @@ def main(): cmake_text = load_cmake() version_parts = split_version(cmake_text)[0] - if not args.no_branch and args.major: + if args.major: if config.branch_on_major: - make_branch(config, "v" + str(version_parts[0])) - if not args.no_branch and args.minor: + if not args.no_branch: + make_branch(config, "v" + str(version_parts[0])) + + if args.minor: if config.branch_on_minor: - make_branch(config, "v" + str(version_parts[0]) + "." + str(version_parts[1])) + if not args.no_branch: + make_branch(config, "v" + str(version_parts[0]) + "." + str(version_parts[1])) + elif config.branch_on_major: + subprocess.call(["git", "checkout", "v" + str(version_parts[0])]) + subprocess.call(["git", "rebase", config.main_branch]) + subprocess.call(["git", "checkout", config.main_branch]) + + if args.patch: + if config.branch_on_minor: + subprocess.call(["git", "checkout", "v" + str(version_parts[0]) + "." + str(version_parts[1])]) + subprocess.call(["git", "rebase", config.main_branch]) + subprocess.call(["git", "checkout", config.main_branch]) + elif config.branch_on_major: + subprocess.call(["git", "checkout", "v" + str(version_parts[0])]) + subprocess.call(["git", "rebase", config.main_branch]) + subprocess.call(["git", "checkout", config.main_branch]) + + sync_branch(config=config, version_parts=version_parts, args=args) subprocess.call(["sh", "-c", "git remote | xargs -L1 git push --all"]) - if not args.no_release and args.major: - if config.release_on_major: + if args.major: + if not args.no_release and config.release_on_major: make_release(env, "v" + str(version_parts[0])) - if not args.no_release and args.minor: - if config.release_on_minor: + if args.minor: + if not args.no_release and config.release_on_minor: make_release(env, "v" + str(version_parts[0]) + "." + str(version_parts[1])) if __name__ == "__main__": From de0c52cfe08bb2860efd07267c93d9c29d202c7f Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:51:25 -0400 Subject: [PATCH 24/32] test patch branch merge gain --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42c9da5..e868387 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.6.1) +project(COSC-4P80-Assignment-1 VERSION 13.6.2) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From 6992be4e56352df4054220dd4be9feb2f7f6f7d7 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:51:54 -0400 Subject: [PATCH 25/32] moving minor branch --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e868387..e4e0310 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.6.2) +project(COSC-4P80-Assignment-1 VERSION 13.7.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From 89c98c5196c0c545b73022f0baf1c376b8aa9dfd Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:52:05 -0400 Subject: [PATCH 26/32] testing major release --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4e0310..236d477 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 13.7.0) +project(COSC-4P80-Assignment-1 VERSION 14.0.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From dd92b2bbccd8bedd09c08eb26f4427d5dd24408a Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:56:25 -0400 Subject: [PATCH 27/32] test minor merge --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 236d477..c041f80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 14.0.0) +project(COSC-4P80-Assignment-1 VERSION 14.1.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From 5a541c50c42c9aa13c2bbd38bbf22c5f10e7025f Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:56:35 -0400 Subject: [PATCH 28/32] test patch merge --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c041f80..b9c8ff0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 14.1.0) +project(COSC-4P80-Assignment-1 VERSION 14.1.1) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From 31b91e2a1cc72d978f09d8ff4977678b6d261c56 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 13:56:47 -0400 Subject: [PATCH 29/32] test minor merge again --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9c8ff0..55e41af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 14.1.1) +project(COSC-4P80-Assignment-1 VERSION 14.2.0) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) From 25f6348323aacf29dd739fadcd1ea48b4a9a14ef Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 15:12:28 -0400 Subject: [PATCH 30/32] silly --- CMakeLists.txt | 2 +- lib/blt | 2 +- src/main.cpp | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55e41af..67191b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 14.2.0) +project(COSC-4P80-Assignment-1 VERSION 14.2.1) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/lib/blt b/lib/blt index 0d13e97..0ecee08 160000 --- a/lib/blt +++ b/lib/blt @@ -1 +1 @@ -Subproject commit 0d13e9738f6f666faec827940948337cef644aba +Subproject commit 0ecee088f6a633be523468843c55b925550ca691 diff --git a/src/main.cpp b/src/main.cpp index 5677efe..459f0ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -132,7 +132,7 @@ int main() BLT_TRACE_STREAM << index << " : " << value.vec_from_column_row() << '\n'; BLT_TRACE(""); - + for (const auto& [index, value] : blt::enumerate(part_c_2_inputs).rev()) BLT_TRACE_STREAM << index << " : " << value.vec_from_column_row() << '\n'; @@ -156,9 +156,14 @@ int main() for (const auto& [index, value] : blt::enumerate(part_c_2_inputs).skip(2).take(3)) BLT_TRACE_STREAM << index << " : " << value.vec_from_column_row() << '\n'; + for (const auto& [a, b] : blt::in_pairs(part_a_inputs, part_a_outputs)) + { + BLT_TRACE_STREAM << a << " : " << b << "\n"; + } + // BLT_TRACE("%s", blt::type_string::type>().c_str()); - - + + // part_a(); // part_b(); // part_c(); From ac7e44ec18ab7afa8221fc0eb191178b3a6758a4 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Sep 2024 18:17:57 -0400 Subject: [PATCH 31/32] i am in hell --- CMakeLists.txt | 2 +- src/main.cpp | 30 +++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67191b0..3cea25e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 14.2.1) +project(COSC-4P80-Assignment-1 VERSION 14.2.2) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/src/main.cpp b/src/main.cpp index 459f0ef..dff61dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -156,11 +156,35 @@ int main() for (const auto& [index, value] : blt::enumerate(part_c_2_inputs).skip(2).take(3)) BLT_TRACE_STREAM << index << " : " << value.vec_from_column_row() << '\n'; - for (const auto& [a, b] : blt::in_pairs(part_a_inputs, part_a_outputs)) + BLT_TRACE(""); + + for (const auto& [a, b] : blt::in_pairs(part_a_inputs, part_a_outputs).enumerate()) { - BLT_TRACE_STREAM << a << " : " << b << "\n"; + auto& [ma, mb] = b; + BLT_TRACE_STREAM << a << " : " << ma.vec_from_column_row() << " " << mb.vec_from_column_row() << "\n"; } - + + BLT_TRACE(""); + + for (const auto& [a, b] : blt::in_pairs(part_a_inputs, part_a_outputs).rev()) + { + BLT_TRACE_STREAM << a.vec_from_column_row() << " : " << b.vec_from_column_row() << "\n"; + } + + BLT_TRACE(""); + + for (const auto& [a, b] : blt::in_pairs(part_a_inputs, part_a_outputs).take(1)) + { + BLT_TRACE_STREAM << a.vec_from_column_row() << " : " << b.vec_from_column_row() << "\n"; + } + + BLT_TRACE(""); + + for (const auto& [a, b] : blt::in_pairs(part_a_inputs, part_a_outputs).skip(1)) + { + BLT_TRACE_STREAM << a.vec_from_column_row() << " : " << b.vec_from_column_row() << "\n"; + } + // BLT_TRACE("%s", blt::type_string::type>().c_str()); From 6543129c80adc0e541f0e22dfed38911ef69e167 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sat, 28 Sep 2024 16:50:44 -0400 Subject: [PATCH 32/32] silly --- CMakeLists.txt | 2 +- lib/blt | 2 +- src/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cea25e..8214a7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 14.2.2) +project(COSC-4P80-Assignment-1 VERSION 14.2.3) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/lib/blt b/lib/blt index 0ecee08..fb3ed3a 160000 --- a/lib/blt +++ b/lib/blt @@ -1 +1 @@ -Subproject commit 0ecee088f6a633be523468843c55b925550ca691 +Subproject commit fb3ed3aa5ee9ac4185dc6228e06b07466fc38e91 diff --git a/src/main.cpp b/src/main.cpp index dff61dd..36aad8e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ #include #include "blt/std/assert.h" #include -#include +#include #include constexpr blt::u32 num_values = 4;