Skip to content

Commit

Permalink
Fix git rev-parse usage
Browse files Browse the repository at this point in the history
it needs ^{} at the end in order to extract a tagged commit from an annotated tag.
Using bare ^ makes it return the parent commit of a tagged commit.
  • Loading branch information
ayoy committed Nov 22, 2024
1 parent 2a6c410 commit 88c20bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def self.details
* pushes the changes to the remote repository,
* creates a new Asana release task based off the provided task template,
* updates the Asana release task with tasks included in the release.
* if it's a hotfix release, it will create a hotfix branch, update the build number and push changes
For hotfix releases, the action creates a hotfix branch off the latest public release tag, updates the build number and pushes the changes.
DETAILS
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def self.create_hotfix_branch(platform, source_version, new_version)
UI.abort_with_message!("Branch #{branch_name} already exists in this repository. Aborting.") unless existing_branch.empty?

if Helper.is_ci?
sha = Actions.sh("git", "rev-parse", "#{source_version}^").strip
sha = Actions.sh("git", "rev-parse", "#{source_version}^{}").strip
repo = Helper::GitHelper.repo_name(platform)
Actions.sh("gh", "api", "--method", "POST", "/repos/#{repo}/git/refs", "-f", "ref=refs/heads/#{branch_name}", "-f", "sha=#{sha}")
Actions.sh("git", "fetch", "origin")
Expand Down
4 changes: 2 additions & 2 deletions spec/ddg_apple_automation_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def load_file(file)
platform = "macos"
allow(Fastlane::Helper).to receive(:is_ci?).and_return(true)
allow(Fastlane::Actions).to receive(:sh).with("git", "branch", "--list", branch_name).and_return("")
allow(Fastlane::Actions).to receive(:sh).with("git", "rev-parse", "#{source_version}^").and_return(sha)
allow(Fastlane::Actions).to receive(:sh).with("git", "rev-parse", "#{source_version}^{}").and_return(sha)
allow(Fastlane::Actions).to receive(:sh).with(
"gh", "api", "--method", "POST",
"/repos/#{repo}/git/refs",
Expand All @@ -184,7 +184,7 @@ def load_file(file)
expect(result).to eq(branch_name)

expect(Fastlane::Actions).to have_received(:sh).with("git", "branch", "--list", branch_name)
expect(Fastlane::Actions).to have_received(:sh).with("git", "rev-parse", "#{source_version}^")
expect(Fastlane::Actions).to have_received(:sh).with("git", "rev-parse", "#{source_version}^{}")
expect(Fastlane::Actions).to have_received(:sh).with(
"gh", "api", "--method", "POST",
"/repos/#{repo}/git/refs",
Expand Down

0 comments on commit 88c20bb

Please sign in to comment.