epicweb-dev / epicshop

The workshop app for all workshops on EpicWeb.dev
https://www.epicweb.dev
Other
205 stars 33 forks source link

update command fails on `git stash pop` #224

Closed htulipe closed 1 month ago

htulipe commented 1 month ago

Hi,

This morning I ran the npm start command on the "Get started" workshop and saw they were some updates available. When running the provided update command I got an error on git stash pop (see command log below).

Oddly enough, rerunning the update command raised no errors and I could run the workshop normally, looks like the update was successful after all.

For context:

Cheers

➜  get-started-with-react git:(main) ✗ npm start

> start
> npx --prefix ./epicshop epicshop start

🐨  Let's get learning!
Local:            http://localhost:5639
On Your Network:  http://172.24.92.20:5639
Press Ctrl+C to stop

 🎉  There are updates available for this workshop repository.  🎉

To get the updates, stop the server and run the following command:

   npx update-epic-workshop 

To view a diff, check:
   https://github.com/epicweb-dev/get-started-with-react/compare/bd33329...30ac3de 
^C
➜  get-started-with-react git:(main) ✗    npx update-epic-workshop 
Need to install the following packages:
update-epic-workshop@4.28.2
Ok to proceed? (y) 

🔍 Updates found.
👀 Here's the diff: https://github.com/epicweb-dev/get-started-with-react/compare/bd33329...30ac3de
👜 Stashing uncommitted changes...
⬇️ Pulling latest changes...
👜 re-applying stashed changes...
❌ Error updating local repo: Command failed with exit code 1: git stash pop

No stash entries found.
➜  get-started-with-react git:(main) ✗ gst
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .env

nothing added to commit but untracked files present (use "git add" to track)
htulipe commented 1 month ago

Okay I'm pretty sure I found the issue. It's coming from the update command which does not handle untracked files well (the .env file in my case).

If I'm running what the command does, the git status --porcelain will report untracked files but the following git stash won't stash them, making the following git stash pop fail. See output below:

➜  get-started-with-react git:(main) ✗ git status --porcelain
?? .env
➜  get-started-with-react git:(main) ✗ git stash
No local changes to save
➜  get-started-with-react git:(main) ✗ git stash pop
No stash entries found.
➜  get-started-with-react git:(main) ✗ echo $?
1

I'll submit a PR

kentcdodds commented 1 month ago

Thank you for the PR!

kentcdodds commented 1 month ago

Also, I should probably add a reference to the root .env to the .gitignore

htulipe commented 1 month ago

You're welcome :)