Actually when the user commits a file into their local repository I need to update come information into those files automatically like for example: version string, for this I use pre-commit hooks.
To update the version string first I need to take the current version of the file from already existing file in bitbucket remote branch. Of Couse I should not take the current version for the file in my local repository since other users could have done some changes and pushed the same file.
To get the file in bitbucket remote branch I wrote a small python script using 'requests' module. So when the file exists in remote branch it returns me the raw content of the file. When the file does not exists it returns status code 404(page not found) . So I assumed that file does not exists! I think this is not the reliable way to say file does not exists in the branch. Is there a reliable way to check if the file exists in the remote branch or not ?
Hi Kailash,
In this case, the git command you want is:
git ls-tree -r <remote_branch>
The git command above should list all files which exists in the specified remote branch -- from there, you should be able to check if a particular file exists in the remote branch or not.
- Vivian
Hi Vivian,
Is it possible to check the existence of a file giving the input as a URL and a branch?
Thanks
Sangeetha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.