Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action]Adds action for obtaining remote repo default branch #18845

Merged
merged 9 commits into from Jun 23, 2021

Conversation

seanmcneil
Copy link
Contributor

@seanmcneil seanmcneil commented Jun 9, 2021

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

This introduces a new action to obtain the default branch name from a remote git repository. Doing this can support other actions such as creating merge requests by ensuring that the proper branch name is provided as a target. With the shift away from "master", it is beneficial to have this kind of flexibility.

Description

A new action has been created in the source control category that enables retrieving a remote git repository's default branch.

It was tested under the following conditions:

  • In a folder with no available git repo (an empty string was returned)
  • In a folder with a git repo, but no available remote (an empty string was returned)
  • In a folder with a valid git repo and the local branch on the default remote (correct branch name returned)
  • In a folder with a valid git repo and the local branch NOT on the default remote (correct branch name returned)

Testing Steps

  • Scenario 1, test in a folder with no git repo. Run bundle exec fastlane run git_default_remote_branch
  • Scenario 2, test in a folder only a local git repo.
    • Init a git repo, commit a file
    • Run bundle exec fastlane run git_default_remote_branch
  • Scenario 3, test in a folder with a valid remote repo
    • Clone a repo, ensure you are on the default branch
    • Run bundle exec fastlane run git_default_remote_branch . Default name should be seen
  • Scenario 4, test in a folder with a valid remote repo while not on default branch
    • Clone a repo, switch to a non-default branch
    • Run bundle exec fastlane run git_default_remote_branch . Default name should be seen

@google-cla google-cla bot added the cla: yes label Jun 9, 2021
@seanmcneil seanmcneil changed the title Adds action for obtaining remote repo default branch [action]Adds action for obtaining remote repo default branch Jun 9, 2021
@fastlane fastlane deleted a comment from naveentnj Jun 11, 2021
Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I totes see a need for this. Just got two small requests 💪

fastlane/lib/fastlane/actions/git_default_remote_branch.rb Outdated Show resolved Hide resolved
fastlane/lib/fastlane/helper/git_helper.rb Outdated Show resolved Hide resolved
Copy link
Member

@crazymanish crazymanish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, one minor suggestion if you agree! 🚀

@seanmcneil
Copy link
Contributor Author

@joshdholtz Can you please check on your change request?

@google-cla
Copy link

google-cla bot commented Jun 23, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jun 23, 2021
@joshdholtz
Copy link
Member

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Jun 23, 2021
Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thank you so much for adding that remote_name option 🙌 I added one commit to clean up some syntax but other than that this is 💯 Really appreciate this ❤️

@joshdholtz joshdholtz merged commit da1fd40 into fastlane:master Jun 23, 2021
Copy link

@fastlane-bot fastlane-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations! 🎉 This was released as part of fastlane 2.186.0 🚀

@fastlane fastlane locked and limited conversation to collaborators Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants