set :deploy_via, :remote_cache this option is not applied to submodules - capistrano

I am using git submodule feature with capistrano. I have
set :deploy_via, :remote_cache
set :git_enable_submodules,1
Everything works great. However remote_cache option is only applied to main app. Which means that every single time I deploy the app all submodules pull in all changes and that takes a lot of time.
Is there a way to tell submodule to use :remote_cache.
Thanks

You need to go deep into capistrano sources, just search for git_enable_submodules and remote_cache.
I think there is no suitable to be used with remote_cache, but that should be no problem as you can copy code that does git_enable_submodules and write your own implementation.
When You have your solution you can fork capistrano add it to code and ask for pull request.

Related

Enabling github pre commit hooks in origin for all collaborators

first: We use a github repository in the team for some projects.
I'm using scripts defined in the pre-commit hook directory, locally (works perfect for my commits).
What I need is for every user (collaborator) to use the hooks without using symlinks or asking them to put them on their home folders.
Is there a way to set them up so the users can't commit if the scripts don't exit 0?.
Thanks.
As Henrik alluded to, in the Enterprise version, there is such a thing as the pre-receive hook. It runs server side and so you would not need to install it on each collaborator's local machine. But you are using github.com actual, and they don't allow pre receive hooks , nor do I expect they plan to; allowing indivduals to run scripts on their server isn't likely in their business plan. So that likely won't help you unless you are in a position to go to the enterprise product
There are some remedies you do have, however, but it won't be equivalent. You can , for example, set a protected branch . You could thereby make it only you can check into that branch, and you of course would be using the local hook, every one else would be using a pull request.
Additionally, you could look into LGTM (Looks Good To Me) or similar automated pull request approval system. I don't believe the official server is up but the source code is there and it could be run by someone else. LGTM allows you to set a number of different conditions that would be closer to an equivalent to your pre-op hook.
Setting up such a system might well be more effort than it is worth to you, understandable; but it is do-able.
The main problem with using pre-commit hooks that come with git is that they are local to your repos and don't get pushed to github.com. I believe under the hood, those hooks aren't even transferred up to the repo on github, and that the pre-commit hook directory itself is not available like it is on the local copy of a git repo.
(I would say more on that architecture of the pre-commit hook dir except A. I am not sure if it is covered by NDA and B. I only saw the way it was on the Enterprise product, not github actual, and C. I don't know if the structure is still exactly the same)

Additional configuration file(s) for Travis CI?

I'm currently contributing through a fork on GitHub to an open source project that uses Travis CI. Turning it on for the fork has been trivial, however I would like to add Slack notifications for our team without affecting the original .travis.yaml, so I was asking myself if it was possible to somehow define a secondary configuration file and add it to .gitignore (if that's ok with the original repo owners). Would this be possible? Is there any other way around the problem?
Looking at the code it seems like .travis.yml is hard-coded and there's no way to override that or have a secondary file, is it?

capistrano v3 deploy git repository and its submodules

With capistrano v2 submodules can be includes in the deploy by using option:
set :git_enable_submodules, 1
In v3 this does not seem to work. Is this option still supported or is there a new way to reach the same goal?
In capistrano 3.1.x and later you can implement your own SCM strategy. There is an available gem that helps with git submodule, please see: https://github.com/i-ekho/capistrano-git-submodule-strategy.
NOTE: you may have problem with the repo folder if you already tried with the default git strategy. Simply go to the deploy directory on server and remove it and then run cap deploy again to fix.
The new Pull Request "828" is trying to implement that again:
https://github.com/capistrano/capistrano/pull/828
As discussed by #coffeeaddict, this Commit is a scrap of the code you will need to deploy locally until it's bundled with the capistrano itself. Please note that you need Capistrano >= 3.1.0 to use the code.
There is also another Gist that suggest to fix some issues of the strategy above.
It turns out it's very difficult to hook into any of the git tasks of capistrano (because they don't exist until the stage is set). Besides, git archive does not in any way provide support for submodules, so that part has to be completely replaced.
Copy and paste is also not an option for obvious reasons.
So I wrote this simple gem that can replace the git scm. It uses a similiar approach to capistrano 2, by cloning the repo with its submodules. It is very simple and enough for our goals. I suspect there are not many different usages of submodules out there (if people try to avoid complications).
https://github.com/juanibiapina/capistrano-scm-gitsubmodules
Let me know if it helps you too.
UPDATE:
This module has been deprecated with capistrano 3.1.0. Try this instead: https://gist.github.com/stevenscg/8176735
As you can see in the Capistrano source code https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/git.rake#L34 and https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/git.rake#L56 it uses git archive to check out the code into the release directory.
The code is reproduced here:
desc 'Clone the repo to the cache'
task clone: :'git:wrapper' do
on roles :all do
if test " [ -f #{repo_path}/HEAD ] "
info t(:mirror_exists, at: repo_path)
else
within deploy_path do
with git_environmental_variables do
execute :git, :clone, '--mirror', repo_url, repo_path
end
end
end
end
end
desc 'Update the repo mirror to reflect the origin state'
task update: :'git:clone' do
on roles :all do
within repo_path do
execute :git, :remote, :update
end
end
end
desc 'Copy repo to releases'
task create_release: :'git:update' do
on roles :all do
with git_environmental_variables do
within repo_path do
execute :mkdir, '-p', release_path
execute :git, :archive, fetch(:branch), '| tar -x -C', release_path
end
end
end
From that we can ascertain that submodules are not supported. As the commands to clone or initialize submodules are never issued, and git-archive ignores them.
The decision was made (source: Capistrano author here) not to include submodules "out of the box" as the hooks needed to build this in, if you need it are already there, and it's trivial to write an add-on task that does what you need to checkout/update submodules in a way that works for you. The Capistrano v2 submodule support often had unexpected consequences for people.
With that in mind. It might be worth to hooking into update, to initialize and update your submodules after the update is finished, and examining ways to augment git-archive do do what you need.

Is there a way to prevent some files from appearing on the main branch in the remote repo?

I'm working on a simple project with other people. They use Eclipse to build it, but I don't like Eclipse and wrote a makefile and some batch/bash scripts to do the job for me.
I want to keep track of changes I make to these files, but I don't want others to see them in the main repo (at least not on the default branch, it would be okay to have my own). I could make a subrepo, but I don't want to type the folder each time I build something (besides, keeping makefile NOT in the root would be a bit awkward).
What are my options?
Use MQ-extension
Have adding these needed (personal local) files in MQ-patch(es)
Work locally with patch applied, unapply patch before push

buildbot force build ignoring repository

When I click on the 'builders' link of builbot URL and force a build, the git repository I specify on the form is getting ignored; the builder is using the repository it was originally built/configured with. Is this a known problem ? Is there some way to force the builder to use the new repo ? I'm running 0.8.4 on Ubuntu 10.04. Thanks for any help.
This is a deliberate choice, as there various potential ways of creating a source stamp, that are insecure. Thus, someone could potentially execute arbitrary code on the slave, if buildbot used whatever repository URL passed into it.
That said, it is easy to get the behavior you want. The simplest is to specify
repourl=Property('repository', '<default-repository>')
which will use the 'repository' property of the build (which gets initialized from the source stamp) or the default repository, if none is specified. (Property is imported from buildbot.process.properties)