From f247c73c58d3b8feac5c0e1adee6234655f7dee8 Mon Sep 17 00:00:00 2001 From: enciyo Date: Mon, 10 Jun 2024 01:52:28 +0300 Subject: [PATCH] Release --- che.properties | 2 +- che/config.json | 6 ++++++ che/utils.py | 22 +++++++++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 che/config.json diff --git a/che.properties b/che.properties index f5ae134..2574433 100644 --- a/che.properties +++ b/che.properties @@ -1,2 +1,2 @@ -version=1.0.11 +version=1.0.12 python=3.11 diff --git a/che/config.json b/che/config.json new file mode 100644 index 0000000..e15fa42 --- /dev/null +++ b/che/config.json @@ -0,0 +1,6 @@ +{ + "port": 9696, + "debug": false, + "project_path": "/Users/mustafakilic/PycharmProjects/gh-che/che", + "listen_url": "https://api.githubcopilot.com/chat/completions" +} \ No newline at end of file diff --git a/che/utils.py b/che/utils.py index f13572a..9476612 100644 --- a/che/utils.py +++ b/che/utils.py @@ -9,12 +9,23 @@ def __author_name(): - return subprocess.run(["git", "config", "user.name"], capture_output=True).stdout.decode("utf-8").strip() + path = os.path.join(get_config()["project_path"]) + return subprocess.run( + f"cd {path} && git config user.name", + capture_output=True, + shell=True, + check=True + ).stdout.decode("utf-8").strip() def __current_branch(): - return subprocess.run(["git", "branch", "--show-current"], capture_output=True).stdout.decode( - "utf-8").strip().replace("/", "-") + path = os.path.join(get_config()["project_path"]) + return subprocess.run( + f"cd {path} && git branch --show-current", + shell=True, + check=True, + capture_output=True + ).stdout.decode("utf-8").strip().replace("/", "-") def create_or_open_file(file_path, mode): @@ -87,3 +98,8 @@ def save_config(config): config_path = os.path.join(os.path.dirname(__file__), "config.json") with open(config_path, "w") as f: json.dump(config, f, indent=2, default=str, ensure_ascii=False) + + +if __name__ == '__main__': + print(__current_branch()) + print(__author_name())