We've been using 'git archive' with our git repos hosted under stash and are considering switching from the ssh to http(s) protocol.
git archive --format=tar --remote=ssh://<stash server>:7999/<PROJECT>/<repo>.git <branch>:<directory>/ | tar xf -
It appears this isn't supported with the http URL:
fatal: Operation not supported by protocol.
Does anyone know if this a limitation of git or of the way stash is servering the repos?
It's a limitation of the git 'smart HTTP' protocol. You can however install the Stash ARchive Plugin from the Marketplace. That plugin adds a 'Download' button to the web interface, but also allows you to create and download an archive zip or tgz for a given branch over HTTP directly. Have a look at https://marketplace.atlassian.com/plugins/com.atlassian.stash.plugin.stash-archive for details.
The only combination I could get to work was adding a few arguments to curl.
curl --user deploy:password -G http://scm-repo.company.com.au:7990/projects/MISSION/repos/webapp/browse/build.xml -d at=refs/tags/1.3.3 -d raw > build.xml
Hope that helps somebody ( I'm using stash v3.2.4. ).
Instead of the download button, does it work via command line. I want a clean file without any html tags. Something like wget https://stash.pv.com/projects/PROJECT/repos/REPO/browse/PATH/FILE.EXT. If I try it I get a file with html tags. How to get clean file as it exists in its original form.
The 'Download' button can be used to download a snapshot of an archive of the repository. It sounds like you just want to download a single file?
You should be able to use the url you mentioned, just append a ?raw to it to get a version without markup.
wget --user=username --password=pwd https://stash.pv.com/projects/PROJECT/repos/REPO/browse/PATH/FILE.EXT?raw
should do the trick.
I get the same html file as output. The file has username and password fields. I tried the exact command as you told.
$ wget --user=user --password=pass https://stash.pv.com/projects/OPSDLY/repos/scm_build/browse/bin/promote_jenkins_config.sh?raw --2013-05-08 09:23:53-- https://stash.pv.com/projects/OPSDLY/repos/scm_build/browse/bin/promote_jenkins_config.sh?raw Resolving stash.pv.com... 172.16.0.29 Connecting to stash.pv.com|172.16.0.29|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://stash.pv.com/login [following] --2013-05-08 09:23:53-- https://stash.pv.com/login Connecting to stash.pv.com|172.16.0.29|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 6038 (5.9K) [text/html] Saving to: `promote_jenkins_config.sh?raw' 100%[============================================================================================>] 6,038 --.-K/s in 0s 2013-05-08 09:23:58 (31.2 MB/s) - `promote_jenkins_config.sh?raw' saved [6038/6038]
I tried the above and also got HTML instead of a file. If I looked at the contents in a browser I could see it was the login page.
Part of the problem is that wget doesn't send the basic authentication headers, and we are redirecting the login page. You can fix that by using curl:
curl --user user:pass https://stash.pv.com/projects/OPSDLY/repos/scm_build/browse/bin/promote_jenkins_config.sh?raw >
At this point you're on your own. I start wonder what you're trying to do? Personally at this point you're better off either just cloning, Git is super-quick, or using the archive plugin. Is there any reason why you just want the sub-directory? Is your Git repository very large and that isn't an option?
git-archive supports specifying a particular path or paths to include in the downloaded zip/tarball, but as mentioned above only supports SSH.
If you really want to be able to download just a subdirectory over http, I'd recommend contributing to the Stash Archive plugin https://bitbucket.org/atlassian/stash-archive (or failing that raising an issue in it) to restrict the downloaded archive to particular files.
I do not have a strong argument in favour of why I require a sub-directory download command, except that we are shifting from Accurev to Git/Stash. Such options were available in Accurev and we need to adapt to how Git/Stash commands work. Some of our repos are quite bulky, so cloning is not the best option. But we will use it if it comes to that. At this point, I am collecting information what all we would need to change. If need be, I will raise an issue in Stash Archive plugin. Having said that, downloading a single file option does solve a majority of the problem.
I suspected that might be the case. Git, and DVCS in general, doesn't lend itself to having a single large repository, especially if there are large binary files involved. You either get the whole repository or nothing. In some instances you might be better of splitting a single repositories into multiple sub-repositories to make such things more manageable. It's not an easy change, and you have to decide how best to manage dependencies between those repositories, but it might be something to think about if you find a single repository unwieldy.
Let me know if you have any more questions about the differences between Accurev and Git.
Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot