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

Feature: #deploy to main or master refs #188

Merged
merged 1 commit into from
Dec 15, 2020

Conversation

mrjonesbot
Copy link

@mrjonesbot mrjonesbot commented Oct 28, 2020

Resolves #184

Heroku has enabled pushing to main by default in a backwards compatible manner (does not affect master branches): https://devcenter.heroku.com/changelog-items/1829

The change checks for the presence of main and the absence of master -- setting the branch ref appropriately.

Avoids manual / global git configs and doesn't break projects where master is still the default branch.

@mrjonesbot mrjonesbot changed the title Deploy to main by default Deploy to "main" by default Oct 28, 2020
@mrjonesbot mrjonesbot force-pushed the 184/deploy-main-to-prod branch 3 times, most recently from 4e586dd to 6614ede Compare October 28, 2020 02:53
@mrjonesbot mrjonesbot changed the title Deploy to "main" by default Enable #deploy to main or master refs Oct 28, 2020
@mrjonesbot mrjonesbot force-pushed the 184/deploy-main-to-prod branch from 6614ede to ce368d3 Compare October 28, 2020 03:05
@mrjonesbot mrjonesbot changed the title Enable #deploy to main or master refs Feature: #deploy to main or master refs Oct 28, 2020
@mrjonesbot mrjonesbot force-pushed the 184/deploy-main-to-prod branch from ce368d3 to a0e1428 Compare October 28, 2020 03:10
)
end
end

def branch_ref
main_ref = `find .git/refs/heads/main`
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to do this using the built-in Git command for finding a ref, just in case the file structure changes later:

# These will be true/false
main_ref_exists = system("git show-ref --verify --quiet refs/heads/master")
master_ref_exists = system("git show-ref --verify --quiet refs/heads/main")

if main_ref_exists && !master_ref_exists
  "main"
else
  "master"
end

@mrjonesbot mrjonesbot force-pushed the 184/deploy-main-to-prod branch 4 times, most recently from e1cef4d to c387eba Compare October 29, 2020 17:01
Checks for the presence of refs/heads/main and absence of
refs/heads/master; if this condition is true, set ref to "main".

If a master ref is present, set ref to "master".
@mrjonesbot mrjonesbot force-pushed the 184/deploy-main-to-prod branch from c387eba to 9fb3c50 Compare October 29, 2020 17:02
@mrjonesbot
Copy link
Author

mrjonesbot commented Dec 15, 2020

@gabebw This has been sitting for a bit, is it ready to merge?

@gabebw
Copy link
Contributor

gabebw commented Dec 15, 2020

@mrjonesbot It looks good to me!

I don't have merge permissions on this repo, though, so it's up to someone who does to merge this.

Perhaps @geoffharcourt can merge it?

expect(Kernel).to have_received(:system).with(git_push_feature_branch_main)
end

it "deploys main production's main for evaluation" do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: I think this is "deploys the main branch to production".

@geoffharcourt
Copy link
Collaborator

Looks great! Thank you for your contribution.

@geoffharcourt geoffharcourt merged commit b4afa60 into thoughtbot:master Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: deploying to main branch on production
3 participants