首页 > 解决方案 > Fastlane can not run git actions in a certain project folder

问题描述

--MainProject
-/fastlane/Fastlane
|
--SwiftPackageManager
|
--KotlinMultiPlatfrom

I have the following projects checked out on my computer.One of the fastlane scripts needs to change directory to KotlinMultiPlatfrom project get the latest tag compare that one with the latest tag in SwiftPackageManager project and create a new XCFrmework if there is a newer version which is not created yet.

The lane looks like following in -/fastlane/Fastlane of MainProject.

lane :generate_KMM_xcframework do
       
       Dir.chdir("../../KotlinMultiPlatfrom") do
          lastTag = last_git_tag(pattern: "xxx*")
          ...
       end
      
       Dir.chdir("../../SwiftPackageManager") do
          lastTag = last_git_tag(pattern: "xxx*")
          ...
          git_commit(path:"./*", message: "SPM version update: #{lastTagTrimmed}")
          add_git_tag(tag: "#{lastTagTrimmed}")
          push_to_git_remote
       end
          ...
  end

The problem is last_git_tag is executed successfully inside KotlinMultiPlatfrom, although the SwiftPackageManager is a valid git repository last_git_tag complains fatal: Not a git repository (or any of the parent directories): .git.

If I call sh git fetch && git tag inside all works fine regarding git and puts Dir.pwd also prints me the correct path.

My question is what can be the difference between both of them accessing the fastlane actions related with git (last_git_tag, git_commit, add_git_tag,push_to_git_remoteaction)

标签: rubygitversion-controlcontinuous-deploymentfastlane

解决方案


推荐阅读