Skip to content

Commit

Permalink
Calculate new repository link from ssh path in configure script (#1614)
Browse files Browse the repository at this point in the history
* Make setup_github bool a global variable

* Calculate new repo link from ssh path in configure script

* Fix regex in setup github script
  • Loading branch information
gazayas authored Oct 30, 2024
1 parent 6ea2c6f commit d34a693
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 5 additions & 1 deletion bin/configure-scripts/deploy_button_heroku.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
add_button = ask_boolean "Would you like to add a 'Deploy to Heroku' button to your project.", "y"
if add_button
puts "Adding a 'Deploy to Heroku' button.".green
new_repo_link = ask "What is the https variant of your repo URL? (Something like: https://github.com/your-org/your-repo)"
new_repo_link = if SETUP_GITHUB
HTTP_PATH
else
ask "What is the https variant of your repo URL? (Something like: https://github.com/your-org/your-repo)"
end

File.open("README.md", "a") do |readme|
button = File.read(button_file)
Expand Down
6 changes: 5 additions & 1 deletion bin/configure-scripts/deploy_button_render.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
add_button = ask_boolean "Would you like to add a 'Deploy to Render' button to your project.", "y"
if add_button
puts "Adding a 'Deploy to Render' button.".green
new_repo_link = ask "What is the https variant of your repo URL? (Something like: https://github.com/your-org/your-repo)"
new_repo_link = if SETUP_GITHUB
HTTP_PATH
else
ask "What is the https variant of your repo URL? (Something like: https://github.com/your-org/your-repo)"
end

File.open("README.md", "a") do |readme|
button = File.read(button_file)
Expand Down
11 changes: 8 additions & 3 deletions bin/configure-scripts/setup_github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
puts "If you would like to use another service like Gitlab to manage your repository,"
puts "you can opt out of this step and set up the repository manually."
puts "(If you're not sure, we suggest going with GitHub)"
setup_github = ask_boolean "Continue setting up with GitHub?", "y"

puts "setup_github = #{setup_github}"
if setup_github
# We use this variable in the `deploy_button_heroku.rb` and `deploy_button_render.rb` scripts.
SETUP_GITHUB = ask_boolean "Continue setting up with GitHub?", "y"

puts "SETUP_GITHUB = #{SETUP_GITHUB}"
if SETUP_GITHUB
if `git remote | grep origin`.strip.length > 0
puts "Repository already has a `origin` remote.".yellow
else
Expand All @@ -31,6 +33,9 @@
if ssh_path == "skip"
puts "Bailing out of GitHub setup.".yellow
return
else
# We use this variable in the `deploy_button_heroku.rb` and `deploy_button_render.rb` scripts.
HTTP_PATH = "https://github.com/#{ssh_path.gsub(/.*:/, "")}".delete_suffix(".git")
end
puts "Setting repository's `origin` remote to `#{ssh_path}`.".green
puts `git remote add origin #{ssh_path}`.chomp
Expand Down

0 comments on commit d34a693

Please sign in to comment.