How to Cache the Source Code directory

Hi, couple of questions here:

  1. You state that cache pull is before git clone step but documentation states something else: " You should not put the Bitrise.io Cache:Pull Step BEFORE the Git Clone Repository Step". A little bit confused here, can you explain which one is correct, or when to use one approach or the other?

  2. I tried saving the last commit sha in $BITRISE_CACHE_DIR and take it on the next build to use it for fastlane change log (release notes) like here. But $BITRISE_CACHE_DIR changes at each build so the file path is not found. Then tried the approach with $BITRISE_SOURCE_DIR like here but still the file is not found between builds even if Reset Repository is set to No. This are the logs:

    ==> Start
     ==> Switching to working directory: /Users/vagrant/git
     + file_path=/Users/vagrant/git/commit.txt
     + '[' '!' -f /Users/vagrant/git/commit.txt ']'
     + echo ' (!) File does not exist'
      (!) File does not exist
     + touch /Users/vagrant/git/commit.txt
     + echo 367ac9341ca07ba0234502446b2852274b0a7d9
     + envman add --key BITRISE_LAST_COMMIT_SHA --value 367ac9341ca07ba0234502446b2852274b0a7d9
     + exit 0
     ==> Script finished with exit code: 0
    
    

Not sure what i am missing here. Can you please help?