Using PHP to check and read a remote GIT file

Hi!

I have been strugeling a bit with this issue during my build of a CI-system. I would like the user to select a git repostirory and branch and let the user install it, however, some settings might need to be set and wanted to read the ANT files “build.properties” and “replace.properties” and show them in the client.

While reading the files, I didn’t want to checkout full projects to do so… so I had do digg around a bit. In the end my colleuge found this page:
http://stackoverflow.com/questions/4135049/how-do-i-check-if-a-file-exists-in-a-remote/4138345#4138345

So, here it goes, this is the code I use to check if there is a file available on the git repo, and what its content is.

Download the files here: PHPGit

It uses the git archive command.

 

There is a slight bug in it when using it as CLI, it prints the strdout. I haven’t fixed that yet.

 

Regards,

Paul Peelen

Posted in Development, PHP Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

 

Categories