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

Initalize git repo when creatin new rails app #27632

Merged
merged 1 commit into from Jan 18, 2017

Conversation

dixpac
Copy link
Contributor

@dixpac dixpac commented Jan 10, 2017

Since Rails is already generating .gitignore, and in 90% of cases when creating new rails app user initialise git repo. Now Rails automatically initialises new git repo on rails new command If --skip-git is not specified.

I've added this as new "step" in generator called version_control in case someone wants to override this when creating custom app builder (maybe not using git as version_control but something else)

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@zachweed
Copy link

There's a large difference between creating a single, small file, and initializing an empty git repository automatically. Also, where is the source indicating that 90% of rails applications use git?

That aside.. If this does get approved then I would highly recommend that we flip the --skip-git to a flag like --with-git so that we assume nothing about what the engineer might be using for version control and allow them to opt-in, if they so choose. In addition to that, it would make sense if you were to also include changes to only create .gitignore when a flag is specified (or not specified).

@dixpac
Copy link
Contributor Author

dixpac commented Jan 10, 2017

@zachweed thanks for the comment :)
Sure there is the huge difference(56k to be exact :)), but since rails generator is already generating .gitignore that means that assumption is made you are going to use git. If that is the case why not to initialize the git repo ?

That being said, I like your idea about using --with-git instead of --skip-git (that was also my initial idea), but since there is already --skip-git, I push this solution to see the reactions about adding this kind of feature to the generator :).

Also, I feel that using --skip is more Rails way then --with in this use case

@zachweed
Copy link

@dixpac I completely agree. I personally don't agree with the .gitignore being created either, which is why I was slightly implying removal of that as well by using something with --with-git. Feel free to ping me if you need any help with any of it :)

@georgeclaghorn
Copy link
Contributor

“Assume nothing“ isn’t really Rails’s modus operandi.

@rafaelfranca
Copy link
Member

Thank you for the pull request but doing this by default means that users now need to have git installed to generated a rails application otherwise it will fail. Can we check if git is present in the machine before running the command?

@dixpac
Copy link
Contributor Author

dixpac commented Jan 11, 2017

@rafaelfranca we can check if git is present, but not sure do we have to because run "git init" command will return false if git is not present and nothing will happen (execution will not fail), new rails app will be initialized normally(without git)

@zachweed
Copy link

@dixpac it may be a good idea to return a message indicating we intended to create an empty git repo but were unable to due to it not being installed.

@@ -205,6 +211,7 @@ def create_root_files
build(:configru)
build(:gitignore) unless options[:skip_git]
build(:gemfile) unless options[:skip_gemfile]
build(:version_control)

Choose a reason for hiding this comment

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

Why not check the options[:skip_git] flag here like how its been done for :gitignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since other developers can create custom AppBuilder templates by overriding rails AppBuilder methods, adding options[:skip_git] here would add more complexity if someone wants to use other version_control system in their templates :)

Copy link
Member

@rafaelfranca rafaelfranca left a comment

Choose a reason for hiding this comment

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

Could you add a CHANGELOG entry?

@dixpac
Copy link
Contributor Author

dixpac commented Jan 11, 2017

@rafaelfranca sure I added CHANGELOG and rebased from master :)

* If `--skip-git` is not specified initalize git repo
 when creating new rails app
@dixpac
Copy link
Contributor Author

dixpac commented Jan 12, 2017

@rafaelfranca I'm not sure why tests are red after I rebased from master :(

@maclover7
Copy link
Contributor

@dixpac restarted the randomly failing build, all green now

@mattwelke
Copy link

I actually like this idea. At first I was thinking "wow, that assumes a lot about the developer's intentions" but then I realized... Yes, and that's probably a good thing in the context of Rails development. Rails is opinionated. Most developers use version control and most developers using version control use Git for it. So I think it is logical to implicitly create a new Git repo during the creation of a new Rails app.

@rafaelfranca rafaelfranca merged commit 8989a50 into rails:master Jan 18, 2017
rafaelfranca added a commit that referenced this pull request Jan 18, 2017
Initalize git repo when creatin new rails app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants