From 5cbaf18c5362de184fb760885e7e77baf9035794 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Sun, 24 Nov 2024 22:13:42 +0100 Subject: [PATCH 1/4] Add code/+matbox/+git/deleteGitTag.m --- .github/workflows/update.yml | 7 +++++++ code/+matbox/+git/deleteGitTag.m | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 code/+matbox/+git/deleteGitTag.m diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 7b0fe32..04eab68 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -28,6 +28,13 @@ jobs: # Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it - name: Check out repo uses: actions/checkout@v4 + with: + # Use `github.head_ref` for PRs and `github.ref_name` for other events + ref: ${{ github.event_name == 'pull_request' ? github.head_ref : github.ref_name }} + + - name: Verify checked-out branch + run: | + echo "Checked out branch: $(git rev-parse --abbrev-ref HEAD)" - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 diff --git a/code/+matbox/+git/deleteGitTag.m b/code/+matbox/+git/deleteGitTag.m new file mode 100644 index 0000000..f9515c7 --- /dev/null +++ b/code/+matbox/+git/deleteGitTag.m @@ -0,0 +1,23 @@ +function deleteGitTag(tagName, projectDirectory) + + arguments + tagName (1,1) string + projectDirectory (1,1) string {mustBeFolder} = pwd + end + + if ~strcmp(pwd, projectDirectory) + currentWorkingDir = pwd; + cleanupObj = onCleanup(@(fn) cd(currentWorkingDir)); + cd(projectDirectory) + end + + %[s,m] = system( '$(git rev-parse --abbrev-ref HEAD) == "main"' ) + + [s1, m1] = system(sprintf("git tag --delete %s", tagName)); + assert(s1==0, 'MATBOX:GitUtility:DeleteTagFailed', ... + 'Failed to delete local tag. Reason: %s', m1); + + [s2, m2] = system(sprintf("git push --delete origin %s", tagName)); + assert(s2==0, 'MATBOX:GitUtility:DeleteTagFailed', ... + 'Failed to delete remote tag. Reason: %s', m2); +end From 6bca943abda8873c163d88d9ea4453903f14df9a Mon Sep 17 00:00:00 2001 From: ehennestad Date: Sun, 24 Nov 2024 22:15:12 +0100 Subject: [PATCH 2/4] Update update.yml --- .github/workflows/update.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 04eab68..4937507 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -29,7 +29,6 @@ jobs: - name: Check out repo uses: actions/checkout@v4 with: - # Use `github.head_ref` for PRs and `github.ref_name` for other events ref: ${{ github.event_name == 'pull_request' ? github.head_ref : github.ref_name }} - name: Verify checked-out branch From a08f51052937960d8b5b6ef795f542a9adcebc2e Mon Sep 17 00:00:00 2001 From: ehennestad Date: Sun, 24 Nov 2024 22:16:19 +0100 Subject: [PATCH 3/4] Update deleteGitTag.m --- code/+matbox/+git/deleteGitTag.m | 1 + 1 file changed, 1 insertion(+) diff --git a/code/+matbox/+git/deleteGitTag.m b/code/+matbox/+git/deleteGitTag.m index f9515c7..30444b8 100644 --- a/code/+matbox/+git/deleteGitTag.m +++ b/code/+matbox/+git/deleteGitTag.m @@ -1,4 +1,5 @@ function deleteGitTag(tagName, projectDirectory) +% deleteGitTag - Delete tag from repository (local and remotely) arguments tagName (1,1) string From e431820c25a7171077c070042b19ba34e11d084f Mon Sep 17 00:00:00 2001 From: ehennestad Date: Sun, 24 Nov 2024 22:20:44 +0100 Subject: [PATCH 4/4] ... --- .github/workflows/update.yml | 2 +- code/+matbox/+git/deleteGitTag.m | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 4937507..ced493a 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -29,7 +29,7 @@ jobs: - name: Check out repo uses: actions/checkout@v4 with: - ref: ${{ github.event_name == 'pull_request' ? github.head_ref : github.ref_name }} + ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} - name: Verify checked-out branch run: | diff --git a/code/+matbox/+git/deleteGitTag.m b/code/+matbox/+git/deleteGitTag.m index 30444b8..ca6e166 100644 --- a/code/+matbox/+git/deleteGitTag.m +++ b/code/+matbox/+git/deleteGitTag.m @@ -1,5 +1,6 @@ function deleteGitTag(tagName, projectDirectory) % deleteGitTag - Delete tag from repository (local and remotely) +% arguments tagName (1,1) string