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

Projects
None yet
9 participants
@dixpac
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot Jan 10, 2017

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.

rails-bot commented Jan 10, 2017

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

This comment has been minimized.

Show comment
Hide comment
@zachweed

zachweed Jan 10, 2017

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).

zachweed commented Jan 10, 2017

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

This comment has been minimized.

Show comment
Hide comment
@dixpac

dixpac Jan 10, 2017

Contributor

@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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@zachweed

zachweed Jan 10, 2017

@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 :)

zachweed commented Jan 10, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@georgeclaghorn

georgeclaghorn Jan 10, 2017

Member

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

Member

georgeclaghorn commented Jan 10, 2017

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

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jan 10, 2017

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?

Member

rafaelfranca commented Jan 10, 2017

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

This comment has been minimized.

Show comment
Hide comment
@dixpac

dixpac Jan 11, 2017

Contributor

@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)

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@zachweed

zachweed Jan 11, 2017

@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.

zachweed commented Jan 11, 2017

@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)

This comment has been minimized.

@PritiKumr

PritiKumr Jan 11, 2017

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

@PritiKumr

PritiKumr Jan 11, 2017

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

This comment has been minimized.

@dixpac

dixpac Jan 11, 2017

Contributor

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 :)

@dixpac

dixpac Jan 11, 2017

Contributor

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 :)

@rafaelfranca

Could you add a CHANGELOG entry?

@dixpac

This comment has been minimized.

Show comment
Hide comment
@dixpac

dixpac Jan 11, 2017

Contributor

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

Contributor

dixpac commented Jan 11, 2017

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

Initalize git repo when creatin new rails app
* If `--skip-git` is not specified initalize git repo
 when creating new rails app
@dixpac

This comment has been minimized.

Show comment
Hide comment
@dixpac

dixpac Jan 12, 2017

Contributor

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

Contributor

dixpac commented Jan 12, 2017

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

@maclover7

This comment has been minimized.

Show comment
Hide comment
@maclover7

maclover7 Jan 12, 2017

Member

@dixpac restarted the randomly failing build, all green now

Member

maclover7 commented Jan 12, 2017

@dixpac restarted the randomly failing build, all green now

@welkie

This comment has been minimized.

Show comment
Hide comment
@welkie

welkie Jan 12, 2017

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.

welkie commented Jan 12, 2017

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

2 checks passed

codeclimate no new or fixed issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

rafaelfranca added a commit that referenced this pull request Jan 18, 2017

Merge pull request #27632 from dixpac/repo_initialize
Initalize git repo when creatin new rails app

@maclover7 maclover7 removed the needs work label Jan 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment