How to test a PR in local CP version

I have found it’s quite easy to use GitHub desktop to get a PR into my local copy of the repo (excuse probably wrong terminology).

Now, I have a copy of a CP website in localhost using XAMPP. To test out the PR I can manually copy the files across from my GitHub folder to the website folder in xampp → htdocs.

Question: Is there some clever way to do this automatically, or does it need to be done manually?

You can checkout the remote code into the very directory where you want to run your local install – give the directory a descriptive name such as C:/xampp/htdocs/classicpress-pr-804. Then, the directory is not only a local repo, it’s also a working site. If you make any changes in your IDE (or whatever you use to edit files) GitHub Desktop will know and you can push changes back (if you need to) without having to copy files around.

Even better than using a new folder for each PR: set up your local development site to be the same folder as your local copy of the ClassicPress repo. For example, C:\xampp\htdocs\classicpress-dev. Make your web server display that folder as a site (you’ll need to set it to serve the src directory or visit that path in your browser) and let GitHub Desktop modify the files in that folder when you check out the code for the PR, then when you refresh in your browser the local dev site will also be updated.

Ah, great. Thanks. I’ll have a play with that. I was thinking to do another post in my GitHub Desktop series to show people how to review and test PRs. But I need to work it out myself first. :smiley:

What happens with stuff in wp-content though? My test site has a lot of images and plugins, and my theme. Will that get overwritten?

1 Like

Not a problem, since the directories for plugins, images, custom themes and all of that are ignored in our git repository, git / GitHub Desktop / etc will never touch those folders.


Ah, that’s perfect. OK, I’ll start testing. I’ll show you the post for checking before I publish. :+1:

1 Like