From a5655b302e822013db785d2a6029c48bf797c52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Fri, 16 Feb 2024 09:29:51 +0100 Subject: [PATCH] Removes additional fetching from git --- .github/workflows/build.yml | 24 ++++++++++++------------ tools/bundle.py | 7 ++++++- tools/lib/common.py | 4 ++-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 929e54d36..581395e31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,12 +20,12 @@ jobs: with: fetch-tags: true # required for "git describe" - - name: Fetch more data from git - run: | - # fetch everything back till the $(ZIG_VERSION) tag. - # https://stackoverflow.com/a/58082274 - git fetch --shallow-exclude ${{ env.ZIG_VERSION }} - git fetch --deepen=2 + # - name: Fetch more data from git + # run: | + # # fetch everything back till the $(ZIG_VERSION) tag. + # # https://stackoverflow.com/a/58082274 + # git fetch --shallow-exclude ${{ env.ZIG_VERSION }} + # git fetch --deepen=2 - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 @@ -54,12 +54,12 @@ jobs: with: fetch-tags: true # required for "git describe" - - name: Fetch more data from git - run: | - # fetch everything back till the $(ZIG_VERSION) tag. - # https://stackoverflow.com/a/58082274 - git fetch --shallow-exclude ${{ env.ZIG_VERSION }} - git fetch --deepen=2 + # - name: Fetch more data from git + # run: | + # # fetch everything back till the $(ZIG_VERSION) tag. + # # https://stackoverflow.com/a/58082274 + # git fetch --shallow-exclude ${{ env.ZIG_VERSION }} + # git fetch --deepen=2 - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 diff --git a/tools/bundle.py b/tools/bundle.py index 30805cbaf..a0b98b594 100755 --- a/tools/bundle.py +++ b/tools/bundle.py @@ -168,7 +168,12 @@ def build_zig_tools(): # Determines the correct version: def get_version_from_git() -> str: - raw_git_out = slurp("git", "describe", "--match", "*.*.*", "--tags", "--abbrev=9", cwd=REPO_ROOT).strip().decode() + raw_git_out = slurp("git", "describe", "--match", "*.*.*", "--tags", "--abbrev=9", cwd=REPO_ROOT, allow_failure=True) + if raw_git_out is not None: + raw_git_out = raw_git_out.strip().decode() + else: + print("failed to get version from git, using 'development'", file=sys.stderr) + return "development" def render_version(major,minor,patch,counter,hash): return f"{major}.{minor}.{patch}-{counter}-{hash}" diff --git a/tools/lib/common.py b/tools/lib/common.py index 4d72ca906..8c4b738e4 100644 --- a/tools/lib/common.py +++ b/tools/lib/common.py @@ -3,14 +3,14 @@ VERBOSE = False -def execute_raw(*args,hide_stderr = False,**kwargs): +def execute_raw(*args,hide_stderr: bool = False, allow_failure: bool = False **kwargs): args = [ str(f) for f in args] if VERBOSE: print(*args) res = subprocess.run(args, **kwargs, check=False) if res.stderr is not None and (not hide_stderr or res.returncode != 0): sys.stderr.buffer.write(res.stderr) - if res.returncode != 0: + if not allow_failure and res.returncode != 0: sys.stderr.write(f"command {' '.join(args)} failed with exit code {res.returncode}") sys.exit(res.returncode) return res