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

feat(gatsby-cli): Initialize the newly cloned repository as git #10868

Merged
merged 7 commits into from
Feb 12, 2019

Conversation

caulagi
Copy link
Contributor

@caulagi caulagi commented Jan 6, 2019

Description

Initialize the newly cloned repository as a git repo. This is useful because a lot of the tooling (shell prompts, grep (via ripgrep), etc) honor .gitignore rules, when the directory has .git. I add the following two lines at the end gatsby new output -

info Initialising git in test
Initialized empty Git repository in /private/tmp/test/.git/

@caulagi caulagi requested a review from a team as a code owner January 6, 2019 17:46
@sidharthachatterjee
Copy link
Contributor

Thank you so much for this @caulagi

Have you considered creating the initial commit as well?

@sidharthachatterjee
Copy link
Contributor

@pieh also makes a great point about creating a .gitignore file if it doesn't exist (if a starter didn't include it by mistake) and ensuring it contains .cache, public and node_modules

Would you like to add these to pull request?

@caulagi
Copy link
Contributor Author

caulagi commented Jan 7, 2019

Thanks. I added the functionality to create a minimal .gitignore if it is missing.

Creating an initial commit should have a switch perhaps, so we can disable it? In that case, it would be a separate PR.

@sidharthachatterjee
Copy link
Contributor

I think we should make an initial commit by default. The Angular CLI, ember-cli and create-react-app do this. Do we want to add a flag to disable this, @pieh? I personally think we can add a flag later if enough people want to be able to opt out.

One more thing (sorry I should've mentioned earlier!): we want to check if the folder is already a mercurial or git repo before calling git init

Presence of .git and .hg should be enough, I think

@pieh
Copy link
Contributor

pieh commented Jan 7, 2019

One more thing (sorry I should've mentioned earlier!): we want to check if the folder is already a mercurial or git repo before calling git init

Presence of .git and .hg should be enough, I think

Just the way we scaffold starters is by cloning starter git repository and purging .git directory (to get rid of git history associated with starter development), so .git won't be there and .hg shouldn't be there? unless someone commits it to git repo?

@sidharthachatterjee
Copy link
Contributor

so .git won't be there and .hg shouldn't be there? unless someone commits it to git repo?

Oh yeah! I was thinking of sites created within a monorepo but that is trickier to test for

@caulagi
Copy link
Contributor Author

caulagi commented Jan 8, 2019

I added an initial git commit. The last few lines now look like this -

info Initialising git in g6
Initialized empty Git repository in /private/tmp/nn/g6/.git/
info Creating minimal .gitignore in g6
info Create initial git commit in g6

@sidharthachatterjee
Copy link
Contributor

LGTM

@wardpeet wardpeet changed the title feat(cli): Initialize the newly cloned repository as git feat(gatsby-cli): Initialize the newly cloned repository as git Feb 8, 2019
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Tested and works 👌

Time to get this merged! Thank you @caulagi to getting this done!

@wardpeet wardpeet merged commit ccd9dcd into gatsbyjs:master Feb 12, 2019
@gatsbot
Copy link

gatsbot bot commented Feb 12, 2019

Holy buckets, @caulagi — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (Currently we’ve got a couple t-shirts available, plus some socks that are really razzing our berries right now.)
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

gurpreet-hanjra pushed a commit to gurpreet-hanjra/gatsby that referenced this pull request Feb 14, 2019
…byjs#10868)

* feat(cli): Initialize the newly cloned repository as git

* Create a minimal gitignore if it is missing

* Make an initial git commit in the new directory

* use cwd instead of chdir
@caulagi caulagi deleted the cli-git-init branch June 10, 2019 11:17
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.

None yet

4 participants