Commit Graph

13 Commits

Author SHA1 Message Date
Timothy Andrew f82d549d26 Accept environment variables from the `pre-receive` script.
1. Starting version 2.11, git changed the way the pre-receive flow works.

  - Previously, the new potential objects would be added to the main repo. If the
    pre-receive passes, the new objects stay in the repo but are linked up. If
    the pre-receive fails, the new objects stay orphaned in the repo, and are
    cleaned up during the next `git gc`.

  - In 2.11, the new potential objects are added to a temporary "alternate object
    directory", that git creates for this purpose. If the pre-receive passes, the
    objects from the alternate object directory are migrated to the main repo. If
    the pre-receive fails the alternate object directory is simply deleted.

2. In our workflow, the pre-recieve script (in `gitlab-shell) calls the
   `/allowed` endpoint, which calls out directly to git to perform
   various checks. These direct calls to git do _not_ have the necessary
   environment variables set which allow access to the "alternate object
   directory" (explained above). Therefore these calls to git are not able to
   access any of the new potential objects to be added during this push.

3. We fix this by accepting the relevant environment variables
   (GIT_ALTERNATE_OBJECT_DIRECTORIES, GIT_OBJECT_DIRECTORY) on the
   `/allowed` endpoint, and then include these environment variables while
   calling out to git.

4. This commit includes (whitelisted) these environment variables while making
   the "force push" check. A `Gitlab::Git::RevList` module is extracted to
   prevent `ForcePush` from being littered with these checks.
2016-12-16 23:32:25 +05:30
Ahmad Sherif c90174afcd Fix Gitlab::Popen.popen thread-safety issue
Fixes #21842
2016-09-13 21:39:46 +02:00
Jacob Vosmaer a93a610bac Use 'git update-ref' for safer web commits 2016-09-02 11:49:40 +02:00
Gabriel Mazetto c9aa19881c Enable Style/SpaceAroundEqualsInParameterDefault cop 2016-08-06 04:03:01 +02:00
Dmitriy Zaporozhets 69454e36f7 Style/RedundantReturn enabled 2015-03-24 18:35:57 -07:00
Jacob Vosmaer 52bc4e79f8 Close standard input in Gitlab::Popen.popen 2015-01-05 11:51:21 +01:00
Jacob Vosmaer 38f4b61a58 Make it possible to call Gitlab::Popen.popen 2014-02-25 11:58:58 +01:00
Jacob Vosmaer 8016cefafe Make the Gitlab::Popen path argument optional 2014-02-25 11:58:22 +01:00
Jacob Vosmaer 0432bdf19e Change Gitlab::Popen to use arrays for commands 2014-02-25 11:57:42 +01:00
Dale Hamel 6d7ced4a23 Whitespace fixes to patch 2013-10-08 13:53:22 -05:00
Dale Hamel 1875141a96 Ensure directory exists before changing in popen
If the directory does not exist, we want to ensure that it does.

Forking repos will fail in some situations because of this issue.
2013-10-08 13:50:46 -05:00
Andrey Kumanyaev 67ccc8b52a Replace old hashes with new 1.9 ruby hashes (rebase) 2013-05-05 18:01:10 +04:00
Dmitriy Zaporozhets 1c5876eb7b Do gitolite calls async. Remove satellite with project remove 2013-01-28 17:22:45 +02:00