summaryrefslogtreecommitdiff
path: root/lib/gitlab/git
Commit message (Collapse)AuthorAgeFilesLines
* Returns correct header data for commits endpointOswaldo Ferreira2017-03-071-6/+9
|
* Fix pagination headers for repository commits api endpointGeorge Andrinopoulos2017-03-071-1/+10
|
* Merge branch ↵Rémy Coutable2017-03-021-2/+6
|\ | | | | | | | | | | | | | | | | | | '28805-download-archive-with-branch-like-feature-xxxx-add-extra-directory-level' into 'master' Ensure archive download is only one directory deep Closes #28805 See merge request !9616
| * Ensure archive download is only one directory deepMark Fletcher2017-03-021-2/+6
| |
* | Enable and autocorrect the CustomErrorClass copSean McGivern2017-03-012-4/+4
|/
* Merge branch '23062-allow-git-log-to-accept-follow-and-skip' into 'master' Robert Speicher2017-02-251-18/+24
|\ | | | | | | | | | | | | Make Git history follow renames again by performing the --skip in Ruby Closes #23062 See merge request !9314
| * Optimize a bit Gitlab::Git::Repository#log_by_shell and its specs23062-allow-git-log-to-accept-follow-and-skipRémy Coutable2017-02-231-11/+11
| | | | | | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
| * Make Git history follow renames again by performing the --skip in RubyRémy Coutable2017-02-231-9/+15
| | | | | | | | | | | | | | | | | | This hack is needed because of an issue when --follow and --skip are passed to git log at the same time. See https://gitlab.com/gitlab-org/gitlab-ce/issues/23062 Signed-off-by: Rémy Coutable <remy@rymai.me>
* | Raise error when no content is providedDouwe Maan2017-02-241-2/+0
| |
* | Address reviewDouwe Maan2017-02-241-15/+21
| |
* | Fix new offensesDouwe Maan2017-02-241-3/+1
| |
* | Consistently create, update, and delete files, taking CRLF settings into accountDouwe Maan2017-02-243-208/+124
|/
* Stylistic tweaksDouwe Maan2017-02-231-4/+4
|
* Revert "Enable Style/DotPosition"Douwe Maan2017-02-231-3/+3
| | | | | | | | | | | | | | | This reverts commit e00fb2bdc2090e9cabeb1eb35a2672a882cc96e9. # Conflicts: # .rubocop.yml # .rubocop_todo.yml # lib/gitlab/ci/config/entry/global.rb # lib/gitlab/ci/config/entry/jobs.rb # spec/lib/gitlab/ci/config/entry/factory_spec.rb # spec/lib/gitlab/ci/config/entry/global_spec.rb # spec/lib/gitlab/ci/config/entry/job_spec.rb # spec/lib/gitlab/ci/status/build/factory_spec.rb # spec/lib/gitlab/incoming_email_spec.rb
* Revert "Prefer leading style for Style/DotPosition"Douwe Maan2017-02-231-3/+3
| | | | This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
* Move up delegate callsDouwe Maan2017-02-231-2/+2
|
* ActiveSupport delegation is preferred over ForwardableDouwe Maan2017-02-231-2/+0
|
* Enable Rails/DelegateDouwe Maan2017-02-232-13/+5
|
* Prefer leading style for Style/DotPositionDouwe Maan2017-02-231-3/+3
|
* Enable Style/DotPositionDouwe Maan2017-02-231-3/+3
|
* Update Rubocop to ruby 2.3zj-drop-ruby-21-testsZ.J. van de Weg2017-02-071-1/+1
|
* Remove some useless require_relative statements26756-fix-already-intialized-constant-warningsRémy Coutable2017-01-173-7/+0
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Use configured git rather than system gituse-configured-gitRobert Schilling2017-01-052-4/+4
|
* Ensure internal Gitlab::Git references use the namespacers-absorb-gitlab_gitRobert Speicher2017-01-045-25/+25
|
* Absorb gitlab_gitRobert Speicher2017-01-0418-0/+2950
|
* Reject blank environment vcariables in Gitlab::Git::RevList25848-fix-git-rev-list-env-parsingRémy Coutable2016-12-201-2/+2
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Implement final review comments from @rymai.25301-git-2.11-force-push-bugTimothy Andrew2016-12-161-6/+8
| | | | | | | | | | - `raise "string"` raises a `RuntimeError` - no need to be explicit - Remove top-level comment in the `RevList` class - Use `%w()` instead of `%w[]` - Extract an `environment_variables` method to cache `env.slice(*ALLOWED_VARIABLES)` - Use `start_with?` for env variable validation instead of regex match - Validation specs for each allowed environment variable were identical. Build them dynamically. - Minor change to `popen3` expectation.
* Implement review comments from @dbalexandre.Timothy Andrew2016-12-161-10/+12
| | | | | | | | - Don't define "allowed environment variables" in two places. - Dispatch to different arities of `Popen.open` without an if/else block. - Use `described_class` instead of explicitly stating the class name within a - spec. - Remove `git_environment_variables_validator_spec` and keep the validation inline.
* Validate environment variables in `Gitlab::Git::RevList`Timothy Andrew2016-12-161-3/+13
| | | | | | | | | | | | The list of environment variables in `Gitlab::Git::RevList` need to be validate to make sure that they don't reference any other project on disk. This commit mixes in `ActiveModel::Validations` into `Gitlab::Git::RevList`, and validates that the environment variables are on the level (using a custom validator class). If the validations fail, the force push is still executed without any environment variables set. Add specs for the validation using shared examples.
* Accept environment variables from the `pre-receive` script.Timothy Andrew2016-12-161-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Clean environment variables when running git hooksfix_custom_hook_envsValery Sizov2016-09-151-5/+7
|
* Merge branch '18627-wildcard-branch-protection' into 'master' Douwe Maan2016-07-071-6/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow specifying protected branches using wildcards Closes #18627 # Tasks - [ ] #18627 !4665 Allow specifying protected branches using wildcards - [x] Find existing usages of protected branches - Protecting branches - `ProtectedBranchesController` is used to mark a branch protected/unprotected - `API::Branches` can be used to mark a branch protected/unprotected - Enforcing branch protection - `Gitlab::GitAccess` has helpers (`can_push_to_branch?`, `check`) that are used to deny pushes if a branch is protected - Over SSH: `gitlab-shell` receives a push, and calls `/allowed` on the GitLab API, which calls `GitAccess.check` - Over HTTP: - `gitlab-workhorse` receives the request, and forwards it to rails - Rails (in the `GitHttpController#git-recieve-pack`) runs basic checks (is the user logged in, not protected branch checks) and returns ok with `GL_ID` and `RepoPath` - `gitlab-workhorse` looks at the response, and calls the relevant `gitlab-shell` action from `git-http/handlePostRPC` - Rest of this flow is the same as the SSH flow above - [x] Implementation - [x] Backend - [x] Change `project#protected_branch?` to look at wildcard protected branches - [x] Change `project#developers_can_push_to_protected_branch?` - [x] Change `project#open_branches` - [x] Better error message when creating a disallowed branch from the Web UI - [x] Frontend - [x] Protected branches page should allow typing out a wildcard pattern - [x] Add help text explaining the use of wildcards - [x] Show matching branches for each protected branch - [x] ~~On the index page~~ - [x] On a show page - [x] Index? - [x] Can't have the "last commit" column for wildcard protected branches - [x] Fix / write tests - [x] What happens if a hook is missing in dev? - [x] Refactor - [x] Test workflows - Create a branch matching a wildcard pattern - Push to a branch matching a wildcard pattern - Force push to a branch matching a wildcard pattern - Delete a branch matching a wildcard pattern - [x] Test using Web UI - [x] Test over SSH - [x] Test over HTTP - [x] Test as developer and master - [x] Investigate performance - [x] Test with a large number of protected branches / branches - [x] Paginate list of protected branches - [x] ~~Possibly rewrite `open_branches`~~ - [x] Add `iid`s to existing `ProtectedBranch`es - [x] Add documentation - [x] Add CHANGELOG entry - [x] Add screenshots - [x] Make sure [build](https://gitlab.com/gitlab-org/gitlab-ce/commit/2f753e3ed2ce681b4444944d521f4419e8ed37f7/builds) passes - [x] Assign to endboss for review - [x] Address @DouweM's comments - [x] `protected_branch_params` - [x] `exact_match` instead of `explicit_match` - [x] When would self.name be blank? - [x] Move `protected_branches.each` to a partial - [x] Move `matching_branches.each` to a partial - [x] If the branch is in @matching_branches, it's not been removed - [x] move this regex to a method and memoize it - [x] `commit_sha` directly for exact matches - [x] Number of matches for wildcard matches, with a link - [x] Wait for [build](https://gitlab.com/gitlab-org/gitlab-ce/commit/43f9ce0e88194b8f719bb1c1e656b7fc13278d56/builds) to pass - [x] Respond to @DouweM's comments - [x] Don't use iid - [x] Controller should use `@project.protected_branches.new` - [x] move the memoization to `def wildcard_regex` - [x] render with `collection: @protected_branches` - [x] Wait for [build](https://gitlab.com/gitlab-org/gitlab-ce/commit/f7beedf122fa0c7aa89e86181fe7499321fb10ca/builds) to pass - [x] Wait for @DouweM's review - [x] Wait for @jschatz1's review - [x] Respond to @jschatz1's comments - [x] Use the new dropdown style - [x] description should be moved to the description section without the styling - [x] Protect button should be disabled when no branch is selected - [x] Update screenshots - [x] Merge conflicts - [x] Make sure [build](https://gitlab.com/gitlab-org/gitlab-ce/commit/20f3cfe8d5540eab64c2ba548043d600b28c61ba/builds) passes - [ ] Revisit performance, possibly with staging/production data - [ ] Get a dump of staging / run against staging live - [ ] Get SSH access to staging - [ ] Wait for review/merge # Screenshots ## Creating wildcard protected branches ![1](/uploads/9446afccfdf6fa381e00c800dd2cc82e/1.png) ![2](/uploads/0b154503b297a818d3577488c575d845/2.png) ![3](/uploads/36217f79df9e41cc1550601f02627fe8/3.png) ![4](/uploads/041ca9bd529bcfa5373fca67e917cbcb/4.png) ### Using the `GLDropdown` component ![2016-06-30_14-16-15](/uploads/508afc2a5e2463c2954641409a560d88/2016-06-30_14-16-15.gif) ## Enforcing wildcard protected branches ### From the Web UI ![Screen_Shot_2016-06-20_at_1.21.18_PM](/uploads/8b5d4b1911e9152698a0488daf1880bc/Screen_Shot_2016-06-20_at_1.21.18_PM.png) ### Over SSH ![SSH](/uploads/7365989d7e4c406ef37b6ae5106442c9/SSH.gif) ### Over HTTPS ![HTTPS](/uploads/a7c0f56ae58efcffc75e6700fa2f4ac0/HTTPS.gif) ## Listing matching branches ![Screen_Shot_2016-06-20_at_1.33.44_PM](/uploads/d054113022f5d7ec64c0e57e501ac104/Screen_Shot_2016-06-20_at_1.33.44_PM.png) See merge request !4665
| * Improve the error message displayed when branch creation fails.Timothy Andrew2016-07-051-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: This feature was developed independently on master while this was in review. I've removed the conflicting bits and left the relevant additions, mainly a test for `Gitlab::Git::Hook`. The original commit message follows: 1. `gitlab-shell` outputs errors to `stderr`, but we weren't using this information, prior to this commit. Now we capture the `stderr`, and display it in the flash message when branch creation fails. 2. This can be used to display better errors for other git operation failures with small tweaks. 3. The return value of `Gitlab::Git::Hook#trigger` is changed from a simple `true`/`false` to a tuple of `[status, errors]`. All usages and tests have been updated to reflect this change. 4. This is only relevant to branch creation _from the Web UI_, since SSH and HTTP pushes access `gitlab-shell` either directly or through `gitlab-workhorse`. 5. A few minor changes need to be made on the `gitlab-shell` end. Right now, the `stderr` message it outputs is prefixed by "GitLab: ", which shows up in our flash message. This is better removed.
* | Raise an error if no protocol is passed to the GitAccess check.Patricio Cano2016-07-051-1/+2
| |
* | Rename ENV['PROTOCOL'] to ENV['GL_PROTOCOL'] to conform to what GitLab Shell ↵Patricio Cano2016-07-051-1/+1
| | | | | | | | expects and make the `protocol` param in `GitAccess` mandatory.
* | Only allow Git Access on the allowed protocolPatricio Cano2016-07-051-1/+2
|/
* Handle custom Git hook result in GitLab UIValery Sizov2016-07-041-2/+7
|
* Better message for git hooks and file locksValery Sizov2016-07-041-4/+9
|
* Fire update hook from GitLabValery Sizov2015-11-301-0/+17
|
* Refactor pre/post receive commit services into one classDmitriy Zaporozhets2015-08-141-0/+59
|
* Move Gitlab::Git out of gitlab coreDmitriy Zaporozhets2013-04-278-638/+0
|
* Fix Gitlab::Git::Repository#commit returns wrong commit, if commit_id is ↵Sato Hiroyuki2013-04-251-1/+10
| | | | "tag name".
* Prevent 500 error on git blame if empty fileDmitriy Zaporozhets2013-04-181-1/+2
|
* symbolize keys for Gitlab::Git::Diff & Gitlab::Git::CommitDmitriy Zaporozhets2013-04-162-7/+9
|
* Fix bug when limit or offset passed as stringDmitriy Zaporozhets2013-04-151-1/+1
|
* Update app code to use Gitlab::Git::DiffDmitriy Zaporozhets2013-04-152-1/+16
|
* Init Gitlab::Git::Diff classDmitriy Zaporozhets2013-04-151-0/+63
|
* Git log follow supportakzhan2013-04-151-2/+2
|
* decorate commits in Gitlab::Git::repository with valid classDmitriy Zaporozhets2013-04-031-4/+10
|
* Refactoring and cleanup. Removed unused commit findersDmitriy Zaporozhets2013-04-034-80/+105
|