Commit Graph

615 Commits

Author SHA1 Message Date
Ahmad Sherif dabc703a29 Migrate Git::Blob.batch to Gitaly
Closes gitaly#985
2018-02-08 00:26:45 +01:00
Francisco Javier López d40912bb49 Removing gitaly flags 2018-02-07 16:33:12 +00:00
Sean McGivern 683984f2e3 Merge branch 'zj-refs-hash' into 'master'
Don't use rugged in Repository#refs_hash

Closes gitaly#880

See merge request gitlab-org/gitlab-ce!16827
2018-02-07 15:42:55 +00:00
Zeger-Jan van de Weg 73e78c4e15
Don't use rugged in Repository#refs_hash
The refs hash is used to determine what branches and tags have a commit
as head in the network graph. The previous implementation depended on
Rugged#references. The problem with this implementation was that it
depended on rugged, but also that it iterated over all references and
thus loading more data than needed if for example the project uses CI/CD
environments, Pipelines, or Merge Requests.

Given only refs are checked the network cares about the GraphHelper#refs
method has no need to reject those, simplifying the method.

Closes gitlab-org/gitaly#880
2018-02-07 15:07:03 +01:00
Robert Speicher 245d937514 Merge branch 'gitaly-lfs-client-prep' into 'master'
Refactor Gitlab::Git code related to LFS changes for Gitaly migration

Closes gitaly#980

See merge request gitlab-org/gitlab-ce!16835
2018-02-06 17:35:08 +00:00
Sean McGivern f81306e76f Merge branch 'jej/upload-file-tracks-lfs' into 'master'
File upload UI obeys LFS filter

Closes #29876

See merge request gitlab-org/gitlab-ce!16412
2018-02-06 16:24:54 +00:00
James Edwards-Jones d2a77094ae File upload UI obeys LFS filters
Uses Lfs::FileModificationHandler to coordinate LFS detection, creation of LfsObject, etc

Caveats:
 1. This isn't used by the multi-file editor / Web IDE
 2. This isn't used on rename. We'd need to be able to download LFS files
    and add them to the commit if they no longer match so not as simple.
 3. We only check the root .gitattributes file, so this should be improved
    to correctly check for nested .gitattributes files in subfolders.
2018-02-06 15:26:25 +00:00
Francisco Javier López 27c08a1689 Allow moving wiki pages from the UI 2018-02-05 17:17:21 +00:00
Rémy Coutable f5990e444a Merge branch 'gitaly-user-squash' into 'master'
Incorporate OperationService.UserSquash Gitaly RPC

Closes gitaly#991

See merge request gitlab-org/gitlab-ce!16899
2018-02-05 10:32:20 +00:00
Grzegorz Bizon 5aea8dc1a6 Merge branch 'fix/remove-duplicated-logic-between-model-and-lib-in-find-branch' into 'master'
Remove repo reloading logic from Repository#find_branch

Closes #42609

See merge request gitlab-org/gitlab-ce!16815
2018-02-03 21:47:28 +00:00
Alejandro Rodríguez e60bf2f256 Incorporate OperationService.UserSquash Gitaly RPC 2018-02-02 19:02:40 -03:00
Ahmad Sherif 05f17e4d72 Remove repo reloading logic from Repository#find_branch
Gitlab::Git::Repository#find_branch has a similar logic.

Fixes #42609
2018-02-02 22:24:54 +01:00
Alejandro Rodríguez 98affa75ed Refactor Gitlab::Git code related to LFS changes for Gitaly migration
We stop relying on Gitlab::Git::Env for the RevList class, and use
Gitlab::Git::Repository#run_git methods inteaad. The refactor also fixes
another issue, since we now top using "path_to_repo" (which is a
Repository model method).
2018-02-02 16:27:01 -03:00
Alejandro Rodríguez 658749ddd3 Fix an issue where sparse checkout wasn't configured correctly
This was affecting the performance of `Gitlab::Git::Repository#squash`.
2018-02-01 17:07:40 -03:00
Robert Speicher 2793e3e1cc Merge branch 'gitaly-970-repo-write-config' into 'master'
Migrate Gitlab::Git::Repository#write_config to Gitaly

Closes gitaly#970

See merge request gitlab-org/gitlab-ce!16730
2018-02-01 19:46:32 +00:00
Rémy Coutable 76b9f1a4c5 Merge branch '42497-rubocop-style-regexpliteral' into 'master'
Enable Style/RegexpLiteral cop

Closes #42497

See merge request gitlab-org/gitlab-ce!16752
2018-02-01 09:11:09 +00:00
Douwe Maan 283c0a9d28 Merge branch 'repository-log-disable-walk' into 'master'
Remove Rugged::Walk implementation of #log

See merge request gitlab-org/gitlab-ce!16798
2018-01-31 21:54:02 +00:00
Takuya Noguchi 2b6307f6ad Enable RuboCop Style/RegexpLiteral 2018-02-01 02:06:07 +09:00
Kim "BKC" Carlbäcker 28bbb4cb47 Migrate Gitlab::Git::Repository#write_config to Gitaly
- Add tests for Repository#write_config
2018-01-31 15:02:31 +01:00
Sean McGivern a0fc0fcc53 Merge branch 'rugged-reference-cache-rescue' into 'master'
Stop rescuing Rugged::Reference in Repository cache

See merge request gitlab-org/gitlab-ce!16770
2018-01-31 14:00:37 +00:00
Jacob Vosmaer afe665d9c0 Remove Rugged::Walk implementation of #log 2018-01-31 11:56:36 +01:00
Ahmad Sherif 1ebb781f6a Migrate Git::Repository#delete_refs to Gitaly
Closes gitaly#967
2018-01-30 23:48:51 +01:00
Jacob Vosmaer a6dbb85e97 Remove Rugged exception in cache rescue 2018-01-30 17:51:56 +01:00
Jacob Vosmaer (GitLab) 5c2fe2d3d7 Decouple more of Repository from Rugged 2018-01-30 16:21:55 +00:00
Jacob Vosmaer (GitLab) e407c2d18f Don't allow Repository#log with limit zero 2018-01-29 15:27:46 +00:00
Ahmad Sherif 2290b438f4 Fix rubocop offenses introduced in !16623 2018-01-25 20:44:16 +01:00
Robert Speicher af95ba2fb4 Merge branch 'feature/migrate-repo-restorer-to-gitaly' into 'master'
Migrate restoring repo from bundle to Gitaly

Closes gitaly#946

See merge request gitlab-org/gitlab-ce!16623
2018-01-25 19:03:51 +00:00
Grzegorz Bizon 9df130ff22 Merge branch 'fix/batch-lfs-pointers-accepting-lazy-enum' into 'master'
Fix .batch_lfs_pointers accepting a lazy enumerator

See merge request gitlab-org/gitlab-ce!16701
2018-01-25 14:28:48 +00:00
Ahmad Sherif 07b0beb004 Fix .batch_lfs_pointers accepting a lazy enumerator 2018-01-25 14:11:27 +01:00
Douwe Maan eab9ffeff6 Merge branch 'revert-430b3f0e' into 'master'
Revert "Merge branch 'remove-rugged-walk' into 'master'"

See merge request gitlab-org/gitlab-ce!16676
2018-01-25 11:15:07 +00:00
Rémy Coutable d2bf53942f Merge branch 'jej/gitattributes-check-at-ref' into 'master'
Can parse root .gitattributes file for a ref

See merge request gitlab-org/gitlab-ce!16418
2018-01-25 11:01:36 +00:00
Jacob Vosmaer (GitLab) 7363aa0b9d Revert "Merge branch 'remove-rugged-walk' into 'master'"
This reverts merge request !16525
2018-01-25 11:03:29 +01:00
Ahmad Sherif 29fa930baf Migrate .batch_lfs_pointers to Gitaly
Closes gitaly#921
2018-01-24 19:02:51 +01:00
Ahmad Sherif 6a28967c14 Migrate restoring repo from bundle to Gitaly
Closes gitaly#946
2018-01-24 19:02:32 +01:00
Ahmad Sherif 24625323a8 Migrate repository bundling to Gitaly
Closes gitaly#929
2018-01-24 12:10:31 +01:00
James Edwards-Jones 0683d31ab1 Can parse root .gitattributes file for a ref 2018-01-24 05:15:37 +00:00
Douwe Maan 09fc32173f Merge branch 'gitaly-user-commit-files' into 'master'
Incorporate Gitaly's OperationService.UserCommitFiles RPC

Closes gitaly#890

See merge request gitlab-org/gitlab-ce!16307
2018-01-23 09:34:59 +00:00
Stan Hu b9c537487f Fix Error 500 when repository has no avatar
Closes #42249
2018-01-20 21:00:39 -08:00
Alejandro Rodríguez 081a584a35 Ensure hooks are deleted regardless of the project forking method 2018-01-19 13:57:17 -03:00
Sean McGivern d7c7061a9c Merge branch 'gitaly-commit-signature' into 'master'
Retrieve commit signatures with Gitaly

Closes gitaly#923

See merge request gitlab-org/gitlab-ce!16467
2018-01-18 14:12:41 +00:00
Jacob Vosmaer (GitLab) 4d87f3bb37 Retrieve commit signatures with Gitaly 2018-01-18 14:10:17 +00:00
Jacob Vosmaer (GitLab) fa52038731 Remove Rugged::Walker from Repository#log 2018-01-18 14:05:14 +00:00
Jacob Vosmaer (GitLab) f4de7309ab Remove unused methods from Gitlab::Git 2018-01-17 09:54:27 +00:00
Stan Hu 3228ac06a0 Merge branch 'jej/lfs-rev-list-handles-non-utf-paths-41627' into 'master'
Prevent RevList failing on non utf8 paths

Closes #41627

See merge request gitlab-org/gitlab-ce!16440
2018-01-16 20:47:17 +00:00
James Edwards-Jones c4dd7b8296 Prevent RevList failing on non utf8 paths 2018-01-16 13:27:59 +00:00
Ahmad Sherif 49d6ed9ded Migrate importing repository to Gitaly
Closes gitaly#907
2018-01-15 14:15:54 +01:00
Ahmad Sherif 831019412f Migrate merged_branch_names to Gitaly
Closes gitaly#851
2018-01-11 14:52:15 +01:00
Zeger-Jan van de Weg 58e17bf3b0
Migrate GitlabProject (re)move project endpoints
Migration is done through a small refactoring, which makes us call
endpoins which are performing the same actions for namespaces.
Tests are added to ensure only the project is removed that should be
removed.

Closes gitlab-org/gitaly#873
2018-01-09 19:23:18 +01:00
Sean McGivern 3013951c73 Merge branch 'remove-commit-tree' into 'master'
Remove the Commit#tree method

See merge request gitlab-org/gitlab-ce!16236
2018-01-08 11:31:10 +00:00
Sean McGivern d42c0ecc02 Merge branch 'gitaly-fetch-internal-remote' into 'master'
Incorporate RemoteService.FetchInternalRemote Gitaly RPC

Closes gitaly#857

See merge request gitlab-org/gitlab-ce!16140
2018-01-08 10:42:35 +00:00
Alejandro Rodríguez 9ff44c2986 Incorporate RemoteService.FetchInternalRemote Gitaly RPC 2018-01-05 15:45:24 -03:00
Lin Jen-Shin (godfat) 33c5630b02 Use --left-right and --max-count for counting diverging commits 2018-01-05 16:52:06 +00:00
Douwe Maan 3bb68efb7a Merge branch 'zj-blob-batch' into 'master'
Reroute batch blobs to single blob RPC

See merge request gitlab-org/gitlab-ce!16082
2018-01-05 10:47:28 +00:00
Jacob Vosmaer ac2cb65ab3 Remove the Commit#tree method 2018-01-04 18:00:28 +01:00
Dmitriy Zaporozhets 58a705aaac Merge branch 'ce-gitaly-remote-mirror-prep' into 'master'
[CE] Move git operations for UpdateRemoteMirrorService into Gitlab::Git

See merge request gitlab-org/gitlab-ce!16023
2018-01-04 16:02:22 +00:00
Sean McGivern a0ae886135 Merge branch 'gitaly-merge-nil' into 'master'
Handle Gitaly aborted merge due to branch update

Closes gitaly#854

See merge request gitlab-org/gitlab-ce!16116
2018-01-04 11:01:02 +00:00
Rémy Coutable 062ea80e64 Merge branch 'feature/add-max-count-to-count-commits-rpc' into 'master'
Add support for max_count option to Git::Repository#count_commits

See merge request gitlab-org/gitlab-ce!16145
2018-01-04 10:58:47 +00:00
Alejandro Rodríguez 1c458d17d7 Move delete_remote_branches from Gitlab::Shell to Gitlab::Git::Repository 2018-01-03 23:07:38 -03:00
Alejandro Rodríguez 43308bd826 Move push_remote_branches from Gitlab::Shell to Gitlab::Git::Repository 2018-01-03 23:06:34 -03:00
Robert Speicher 946a3634bc Merge branch 'sh-optimize-commit-stats' into 'master'
Speed up generation of commit stats by using Rugged native methods

See merge request gitlab-org/gitlab-ce!16186
2018-01-03 17:39:24 +00:00
Jacob Vosmaer 449b59ec69 Better English 2018-01-03 12:54:47 +01:00
Jacob Vosmaer 8cf0ea4469 Handle Gitaly aborted merge due to branch update 2018-01-03 12:02:37 +01:00
Stan Hu 25a868753b Speed up generation of commit stats by using Rugged native methods
The previous implementation iterated across the entire patch set
to determine the number of lines added, deleted, and changed. Rugged
has a native method `Rugged::Diff#stat` that does this already,
which appears to be a little faster and require less RAM than doing
this ourselves.

Improves performance in #41524
2018-01-02 23:48:19 -08:00
Ahmad Sherif 4b5b43383a Migrate repo forking to Gitaly
Closes gitaly#825
2018-01-02 17:20:01 +01:00
Zeger-Jan van de Weg 59e50e33b3
Reroute batch blobs to single blob RPC
Given the priorities shifted for the Gitaly team, this endpoint does not
get a dedicated endpoint yet. To make it work in a cloud native
environment the request needs to go to Gitaly, not rugged. This is
achieved by rerouting to the generic TreeEntry endpoint.
2018-01-02 10:00:24 +01:00
Ahmad Sherif 13932b0b12 Add support for max_count option to Git::Repository#count_commits 2017-12-27 14:16:24 +01:00
Dmitriy Zaporozhets 87bae6d42f Merge branch 'gitaly-remotes' into 'master'
Incorporate Gitaly's RemoteService RPCs

Closes gitaly#852

See merge request gitlab-org/gitlab-ce!16060
2017-12-25 10:43:04 +00:00
Alejandro Rodríguez 2694355bb6 Incorporate Gitaly's RemoteService RPCs 2017-12-22 20:30:08 -03:00
Alejandro Rodríguez 7354c9f75d Remove unused method `remote_exists?` 2017-12-22 20:30:07 -03:00
blackst0ne 27c95364b5 Replace '.team << [user, role]' with 'add_role(user)' in specs 2017-12-22 19:18:28 +11:00
Valery Sizov 8b13bdbe4d
[CE->EE] Fix spec/lib/gitlab/git/gitlab_projects_spec.rb 2017-12-19 14:54:45 +00:00
Nick Thomas 4b785df27b
Import gitlab_projects.rb from gitlab-shell
By importing this Ruby code into gitlab-rails (and gitaly-ruby), we avoid
200ms of startup time for each gitlab_projects subprocess we are eliminating.

By not having a gitlab_projects subprocess between gitlab-rails / sidekiq and
any git subprocesses (e.g. for fork_project, fetch_remote, etc, calls), we can
also manage these git processes more cleanly, and avoid sending SIGKILL to them
2017-12-14 16:00:04 +00:00
Robert Speicher 6930fa3102 Merge branch 'gitaly-mirroring-prep' into 'master'
Gitaly mirroring migration prep

Closes gitaly#816

See merge request gitlab-org/gitlab-ce!15775
2017-12-11 20:50:07 +00:00
Bob Van Landuyt f1ae1e39ce Move the circuitbreaker check out in a separate process
Moving the check out of the general requests, makes sure we don't have
any slowdown in the regular requests.

To keep the process performing this checks small, the check is still
performed inside a unicorn. But that is called from a process running
on the same server.

Because the checks are now done outside normal request, we can have a
simpler failure strategy:

The check is now performed in the background every
`circuitbreaker_check_interval`. Failures are logged in redis. The
failures are reset when the check succeeds. Per check we will try
`circuitbreaker_access_retries` times within
`circuitbreaker_storage_timeout` seconds.

When the number of failures exceeds
`circuitbreaker_failure_count_threshold`, we will block access to the
storage.

After `failure_reset_time` of no checks, we will clear the stored
failures. This could happen when the process that performs the checks
is not running.
2017-12-08 09:11:39 +01:00
Zeger-Jan van de Weg 03ac8d5d0b Remove Rugged::Repository#empty? 2017-12-07 15:33:30 +00:00
Alejandro Rodríguez 885a4da208 Add feature flag to use gitaly-ssh mirroring when cloning internal repos
This also allows us to simplify the naming since we can make some
fetching methods private.
2017-12-06 18:41:45 -03:00
Kim "BKC" Carlbäcker 49dd62ada1 Migrate Gitlab::Git::Commit.shas_with_signatures
- Added tests for Git::Commit.shas_with_signatures
2017-12-05 14:43:46 +01:00
Bob Van Landuyt b72d243872 Keep track of all storage keys in a set
That way we don't need the to scan the entire keyspace to get all
known keys
2017-12-01 17:50:43 +01:00
Stan Hu 66127221fe Gracefully handle case when repository's root ref does not exist
This was failing regularly with an Error 500 when the API branches endpoint
was used.

Closes #40615
2017-11-30 23:21:44 -08:00
Sean McGivern dd11f0e053 Merge branch 'dm-cleanup-fetch-and-mirror-methods' into 'master'
Clean up repository fetch and mirror methods

See merge request gitlab-org/gitlab-ce!15424
2017-11-23 17:01:47 +00:00
Douwe Maan 0e6beaf50c Clean up repository fetch and mirror methods 2017-11-23 16:59:50 +01:00
Douwe Maan dbf97574dc Merge branch '39887-move-identical-check-to-merged-branches' into 'master'
Move identical merged branch check to merged_branch_names

Closes #39887

See merge request gitlab-org/gitlab-ce!15464
2017-11-23 15:16:37 +00:00
Jacob Vosmaer (GitLab) 4cfcc97544 Fix encoding bugs in Gitlab::Git::User 2017-11-23 10:48:57 +00:00
Lin Jen-Shin 5951320075 Make sure repository is restored 2017-11-23 18:26:41 +08:00
Lin Jen-Shin 7df1cb528e Move identical merged branch check to merged_branch_names 2017-11-23 18:26:41 +08:00
Douwe Maan 4b78f70fc4 Merge branch 'gitaly-delete-refs' into 'master'
Incorporate Gitaly's RefService.DeleteRefs RPC

Closes gitaly#740

See merge request gitlab-org/gitlab-ce!15460
2017-11-20 15:20:40 +00:00
Rémy Coutable 4f09d099e9 Merge branch '18040-rubocop-line-break-after-guard-clause' into 'master'
Adds Rubocop rule for line break after guard clause

Closes #18040

See merge request gitlab-org/gitlab-ce!15188
2017-11-20 09:22:14 +00:00
Alejandro Rodríguez 3f0c9e9708 Fix Gitlab::Git::Repository#remote_tags using unexisting variable 2017-11-20 09:08:09 +00:00
Alejandro Rodríguez 38730a2d07 Incorporate Gitaly's RefService.DeleteRefs RPC 2017-11-17 18:08:50 -03:00
Jacopo 181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
Jacob Vosmaer (GitLab) de301d13bb Prepare Repository#fetch_source_branch for migration 2017-11-10 14:45:23 +00:00
Yorick Peterse 4dfe26cd8b
Rewrite the GitHub importer from scratch
Prior to this MR there were two GitHub related importers:

* Github::Import: the main importer used for GitHub projects
* Gitlab::GithubImport: importer that's somewhat confusingly used for
  importing Gitea projects (apparently they have a compatible API)

This MR renames the Gitea importer to Gitlab::LegacyGithubImport and
introduces a new GitHub importer in the Gitlab::GithubImport namespace.
This new GitHub importer uses Sidekiq for importing multiple resources
in parallel, though it also has the ability to import data sequentially
should this be necessary.

The new code is spread across the following directories:

* lib/gitlab/github_import: this directory contains most of the importer
  code such as the classes used for importing resources.
* app/workers/gitlab/github_import: this directory contains the Sidekiq
  workers, most of which simply use the code from the directory above.
* app/workers/concerns/gitlab/github_import: this directory provides a
  few modules that are included in every GitHub importer worker.

== Stages

The import work is divided into separate stages, with each stage
importing a specific set of data. Stages will schedule the work that
needs to be performed, followed by scheduling a job for the
"AdvanceStageWorker" worker. This worker will periodically check if all
work is completed and schedule the next stage if this is the case. If
work is not yet completed this worker will reschedule itself.

Using this approach we don't have to block threads by calling `sleep()`,
as doing so for large projects could block the thread from doing any
work for many hours.

== Retrying Work

Workers will reschedule themselves whenever necessary. For example,
hitting the GitHub API's rate limit will result in jobs rescheduling
themselves. These jobs are not processed until the rate limit has been
reset.

== User Lookups

Part of the importing process involves looking up user details in the
GitHub API so we can map them to GitLab users. The old importer used
an in-memory cache, but this obviously doesn't work when the work is
spread across different threads.

The new importer uses a Redis cache and makes sure we only perform
API/database calls if absolutely necessary.  Frequently used keys are
refreshed, and lookup misses are also cached; removing the need for
performing API/database calls if we know we don't have the data we're
looking for.

== Performance & Models

The new importer in various places uses raw INSERT statements (as
generated by `Gitlab::Database.bulk_insert`) instead of using Rails
models. This allows us to bypass any validations and callbacks,
drastically reducing the number of SQL queries and Gitaly RPC calls
necessary to import projects.

To ensure the code produces valid data the corresponding tests check if
the produced rows are valid according to the model validation rules.
2017-11-07 23:24:59 +01:00
Sean McGivern 045795d0d9 Merge branch 'remove-ensure-ref-fetched-from-controllers' into 'master'
removed the #ensure_ref_fetched from all controllers

Closes #36061

See merge request gitlab-org/gitlab-ce!15129
2017-11-06 17:10:18 +00:00
Douwe Maan a2cd9ad251 Merge branch 'jej/fix-lfs-changes-laziness' into 'master'
Implement lazy popen so LfsChanges doesn't have to wait for rev-list to complete

See merge request gitlab-org/gitlab-ce!15180
2017-11-06 11:34:10 +00:00
James Edwards-Jones ca049902dc Gitlab::Git::RevList and LfsChanges use lazy popen 2017-11-06 10:20:14 +00:00
James Edwards-Jones 95640413e6 Gitlab::Git::Popen can lazily hand output to a block
This allows input to start processing immediately without waiting for the process to complete.
This also allows long or infinite inputs to be partially processed,
which will termiate the process when reading stops with SIGPIPE.
2017-11-06 10:20:13 +00:00
Alejandro Rodríguez dea6d054cd Encapsulate git operations for mirroring in Gitlab::Git 2017-11-03 14:33:24 -03:00
Alejandro Rodríguez 88d2517e36 Add `Gitlab::Git::Repository#fetch` command 2017-11-03 14:33:24 -03:00
micael.bergeron cd88fa8f80 removed the #ensure_ref_fetched from all controllers
also, I refactored the MergeRequest#fetch_ref method to express
the side-effect that this method has.

  MergeRequest#fetch_ref -> MergeRequest#fetch_ref!
  Repository#fetch_source_branch -> Repository#fetch_source_branch!
2017-11-03 08:13:11 -04:00
Rémy Coutable 6a5e8f1046 Merge branch 'gitaly-ff-merge' into 'master'
Incorporate Gitaly's OperationService.UserFFBranch RPC

Closes gitaly#693

See merge request gitlab-org/gitlab-ce!15040
2017-11-02 16:11:53 +00:00
Kim Carlbäcker d6066870cc Fix encoding issue with Repository.ls_files 2017-11-02 08:29:03 +00:00
Douwe Maan e65bbc0ca4 Merge branch 'jej/lfs-change-detection' into 'master'
Detect changes to LFS pointers for pruning and integrity check

See merge request gitlab-org/gitlab-ce!14785
2017-11-01 17:33:41 +00:00
James Edwards-Jones fb3f9c6e50 Detect changes to LFS pointers for pruning and integrity check
Gitlab::Git::Blob.batch_lfs_metadata can be used to check for LFS pointers. It uses a lazy enumorator and filters by blob size
2017-11-01 16:41:05 +00:00
Alejandro Rodríguez 37cc50f843 Incorporate Gitaly's OperationService.UserFFBranch RPC 2017-10-31 16:28:09 -03:00
Lin Jen-Shin (godfat) 57d7ed05d9 Fetch the merged branches at once 2017-10-27 15:55:08 +00:00
Alejandro Rodríguez 42a45392a9 Fix the incorrect value being used to set GL_USERNAME on hooks 2017-10-25 14:01:57 -03:00
Rémy Coutable 53ab16f6ff Merge branch 'gitaly-ff-merge-preparation' into 'master'
Move all rugged operation for ff_merge inside Gitlab::Git

Closes gitaly#683

See merge request gitlab-org/gitlab-ce!15011
2017-10-25 12:42:25 +00:00
Alejandro Rodríguez a64601b929 Move all rugged operation for ff_merge inside Gitlab::Git
We also delete some unused code related to the aforementioned feature.
2017-10-24 14:31:52 -03:00
Douwe Maan 30a8d2def3 Merge branch 'gitaly-gl-username' into 'master'
Support `Gitaly::User`'s gl_username field

See merge request gitlab-org/gitlab-ce!15016
2017-10-24 13:59:44 +00:00
Alejandro Rodríguez 4969f486f2 Support `Gitaly::User`'s gl_username field
We also unify conversions from and to `Gitaly::User`s in the
`Gitlab::Git::User` class.
2017-10-23 17:31:48 -03:00
Bob Van Landuyt 705c15d7af Allow enabling the circuitbreaker using an env variable
That way we can enable the circuitbreaker for just one host at a time.
2017-10-23 13:53:49 +03:00
Bob Van Landuyt 591ee4e361 Perform the stat check multiple times when checking a storage
Instead of only checking once within a timeout, check multiple times
within a timeout.

That means with a timeout of 30 seconds and 3 retries. Each try would
be allowed 20 seconds.
2017-10-23 13:53:49 +03:00
Bob Van Landuyt 430e767139 Implement backoff for the circuitbreaker
The circuitbreaker now has 2 failure modes:

- Backing off: This will raise the `Gitlab::Git::Storage::Failing`
  exception. Access to the shard is blocked temporarily.
- Circuit broken: This will raise the
  `Gitlab::Git::Storage::CircuitBroken` exception. Access to the shard
  will be blocked until the failures are reset.
2017-10-23 12:02:23 +03:00
Rémy Coutable 89f5ede2a3 Merge branch 'bvl-do-not-use-redis-keys' into 'master'
Avoid using `Redis#keys`

See merge request gitlab-org/gitlab-ce!14889
2017-10-17 16:15:44 +00:00
Bob Van Landuyt c365dea887 Don't use `Redis#keys` in the circuitbreaker 2017-10-17 12:47:20 +02:00
Douwe Maan 4bbdab764d Merge branch 'bvl-circuitbreaker-improvements' into 'master'
Make the circuitbreaker configurable at runtime

See merge request gitlab-org/gitlab-ce!14842
2017-10-17 10:43:05 +00:00
Bob Van Landuyt 619021fd7a Read circuitbreaker settings from `Gitlab::CurrentSettings`
Instead of from the configuration file
2017-10-17 11:50:32 +02:00
Sean McGivern 980423f6da Merge branch 'git-env-handle-arrays' into 'master'
Add Gitlab::Git::Env.to_env_hash

See merge request gitlab-org/gitlab-ce!14841
2017-10-16 12:37:02 +00:00
Jacob Vosmaer e73af42239 Add Gitlab::Git::Env.to_env_hash 2017-10-16 13:19:44 +02:00
Sean McGivern b2553840e8 Merge branch 'conflict-resolution-refactor' into 'master'
Conflict resolution refactor

See merge request gitlab-org/gitlab-ce!14747
2017-10-16 10:36:06 +00:00
Andrew Newdigate f530261773 Popen with a timeout 2017-10-16 09:11:31 +00:00
Jacob Vosmaer 0aff29f96b Merge Merge Requests via Gitaly 2017-10-13 14:07:31 +02:00
Alejandro Rodríguez faa9bd402d Create a Gitlab::Git submodule for conlict-related files
Rename classes to (hopefully) clearer names while we're doing that.
2017-10-12 22:03:15 -03:00
Alejandro Rodríguez 3fcab51ebb Refactor conflict resolution to contain git ops within Gitlab::Git
This prepares the codebase for a Gitaly migration. See
https://gitlab.com/gitlab-org/gitaly/issues/553
2017-10-12 22:03:14 -03:00
Douwe Maan 05f46b820e Merge branch 'fix/rugged-alternate-paths' into 'master'
Fix the format of rugged alternate directory list

Closes #39046

See merge request gitlab-org/gitlab-ce!14840
2017-10-12 15:37:14 +00:00
Dmitriy Zaporozhets 400557f0ba Merge branch 'gitaly-fetch-remote' into 'master'
Add `Gitlab::Git::Repository#fetch` command

Closes gitaly#586

See merge request gitlab-org/gitlab-ce!14772
2017-10-12 14:53:32 +00:00
Ahmad Sherif a24abf39bf Fix the format of rugged alternate directory list
Fixes #39046
2017-10-12 14:20:04 +02:00
Ahmad Sherif 4378f56c7b Pass git object dir attributes as relative paths to Gitaly
Fixes gitaly#629
2017-10-11 15:46:55 +02:00
Alejandro Rodríguez 1731934398 Add `Gitlab::Git::Repository#fetch` command 2017-10-09 18:25:24 -03:00
Jacopo 0ce6785851 Replaces `tag: true` into `:tag` in the specs
Replaces all the explicit include metadata syntax in the specs (tag:
true) into the implicit one (:tag).
Added a cop to prevent future errors and handle autocorrection.
2017-10-07 13:57:54 +02:00
Jacob Vosmaer 147e2b21be Let fetch_ref pull from Gitaly instead of from disk 2017-10-04 12:57:41 +02:00
Douwe Maan c6e5a77e51 Merge branch 'gitaly-delete-branch' into 'master'
Implement OperationService.UserDeleteBranch Gitaly RPC

See merge request gitlab-org/gitlab-ce!14603
2017-10-04 07:34:33 +00:00
Alejandro Rodríguez 79719cf003 Add OperationService.UserDeleteBranch Gitaly RPC 2017-10-03 21:06:34 -03:00
Jacob Vosmaer (GitLab) bfd53aa6d0 Restore User.from_gitaly 2017-10-03 16:53:11 +00:00
Douwe Maan 4716e81f9d Merge branch 'revert-configurable-size-limits' into 'master'
Revert "Increase diff limits to 100 KB for collapse and 200 KB overall"

See merge request gitlab-org/gitlab-ce!14628
2017-10-02 14:39:55 +00:00
Sean McGivern a5d47bb063 Revert "Increase diff limits to 100 KB for collapse and 200 KB overall"
This reverts commit 1d3c33b57e.
2017-10-02 13:54:40 +01:00
Sean McGivern 0a69abdb28 Merge branch 'gitaly-add-branch' into 'master'
Implement OperationService.UserAddBranch Gitaly RPC

Closes gitaly#544

See merge request gitlab-org/gitlab-ce!14522
2017-10-02 09:27:23 +00:00
Alejandro Rodríguez a97ff8aae0 Add a factory for `Gitaly::GitCommit`s 2017-09-30 00:51:16 -03:00
David Turner dbcf48af8b Add username as GL_USERNAME in hooks (http)
When calling pre-receive, post-receive, and update hooks, add the GitLab
username as the GL_USERNAME environment variable.

This patch only handles cases where pushes are over http, or via
the web interface.  Later, we will address the ssh case.
2017-09-29 18:12:03 -04:00
Jacob Vosmaer (GitLab) 403712f06e Make Repository#has_visible_content more efficient 2017-09-29 13:08:44 +00:00
Sean McGivern b63e8d64c1 Handle error when fetching ref for MR with deleted source branch
If the ref doesn't exist, and the source branch is deleted, we can't get it back
easily. Previously, we ignored this error by shelling out, so replicate that
behaviour.
2017-09-28 11:11:10 +01:00
Kim "BKC" Carlbäcker 9c16958c30 Migrate Gitlab::Git::Repository#log to Gitaly 2017-09-25 11:34:10 +02:00
Douwe Maan 7cf8e0981a Merge branch '36549-circuit-breaker-handles-missing-storages' into 'master'
Allow the git circuit breaker to correctly handle missing repository storages

Closes #36549

See merge request gitlab-org/gitlab-ce!14417
2017-09-22 20:24:22 +00:00
Douwe Maan 408c595292 Merge branch 'sh-blob-raw-check' into 'master'
Ensure that Blob.raw returns always returns a valid blob object

See merge request gitlab-org/gitlab-ce!14412
2017-09-22 10:40:27 +00:00
Nick Thomas ba0ebbb510 Allow the git circuit breaker to correctly handle missing repository storages 2017-09-22 10:05:28 +01:00
Stan Hu 794b4c5579 Ensure that Blob.raw returns always returns a valid blob object
In gitlab-org/gitlab-ee!2976, we saw that a given OID could point
to a commit, which would cause the delta size check to fail.
Gitaly already returns nil if the OID isn't a blob, so this change
makes the Rugged implementation consistent.
2017-09-21 14:49:51 -04:00
Robin Bobbitt fbe205f92f Display full pre-receive and post-receive hook output in GitLab UI 2017-09-21 09:13:00 -04:00
Alejandro Rodríguez 34eeac6108 Use Gitlab::Git's Popen on that module's code
This allows the current Gitaly migration to depend on less code outside
of the Gitlab::Git module
2017-09-20 13:21:54 +02:00
Jacob Vosmaer 9e40baba1e Rename Gitlab::Git::Committer to User 2017-09-14 17:42:02 +02:00
Kim "BKC" Carlbäcker 25c34608b9 Migrate Git::CommitStats to Gitaly 2017-09-11 21:00:58 +02:00
Alejandro Rodríguez c2e99b40f7 Implement fix for n+1 issue on `flatten_tree` helper 2017-09-06 17:47:25 -03:00
Robert Speicher 86cbf60cbb Merge branch 'feature/migrate-branch-operations-to-gitaly' into 'master'
Migrate creating/deleting a branch to Gitaly

See merge request !13864
2017-09-06 17:26:05 +00:00
Ahmad Sherif 41ef94e777 Migrate creating/deleting a branch to Gitaly 2017-09-06 17:25:17 +02:00
micael.bergeron 46f6092a6d [ci-skip] spec for an instance method 2017-09-06 09:44:12 -04:00
micael.bergeron 5625b0e453 add .json_safe_diff spec 2017-09-06 09:01:53 -04:00
Ahmad Sherif e10437de40 Migrate Gitlab::Git::Repository#find_branch to Gitaly 2017-09-05 17:29:45 +00:00
Lin Jen-Shin c5553ce772 Use `git update-ref --stdin -z` to delete refs 2017-08-30 22:01:23 +08:00
Robert Speicher 51ceacb1fc Add missing third argument to `Git::Repository#initialize` in spec 2017-08-24 17:34:05 -04:00
Sean McGivern e46a3d2fda Merge branch 'git-operation-user' into 'master'
Move GitHooksService into Gitlab::Git

See merge request !13739
2017-08-24 14:32:17 +00:00
Andrew Newdigate fb49c94e49 Delegate Repository::branch_exists? and ref_exists? to Gitlab::Git 2017-08-24 09:20:04 +00:00
Douwe Maan 93ad83443a Merge branch 'sh-fix-branch-count' into 'master'
Fix inconsistent number of branches when remote branches are present

Closes #36934

See merge request !13784
2017-08-24 07:42:30 +00:00
Stan Hu 37904108b9 Fix inconsistent number of branches when remote branches are present
Users of project mirrors would see that the number of branches did not
match the number in the branch dropdown because remote branches were
counted when Rugged was in use. With Gitaly, only local branches
are counted.

Closes #36934
2017-08-23 22:07:32 -07:00
Jacob Vosmaer 961da7d0a7 Add tests for Committer#== 2017-08-23 17:23:28 +02:00
Jacob Vosmaer c47b947a73 Move GitHooksService tests 2017-08-23 10:45:20 +02:00
Jacob Vosmaer 65f83941c3 Make gl_repository a G::G::Repository attribute 2017-08-23 10:45:20 +02:00
Robert Speicher a6fbd8648e Stub `ForkedStorageCheck.storage_available?` by default in all specs
Add `:broken_storage` metadata to examples to disable this behavior only
when necessary.
2017-08-22 13:06:25 -04:00
Jacob Vosmaer faaed0aa1f Delete unused Gitlab::Git methods 2017-08-18 14:12:17 +02:00
Andrew Newdigate aaa887feba Client Implementation: RefService::RefExists 2017-08-18 09:43:58 +01:00
Rémy Coutable 4e0ee10a72 Merge branch 'bvl-circuitbreaker-settings-to-avoid-failures' into 'master'
Circuitbreaker settings to avoid spec-failures

Closes #36324

See merge request !13519
2017-08-16 13:38:00 +00:00
Bob Van Landuyt ee603a0089 Allow a `failure_wait_time` of 0 for storage access
This allows testing every storage attempt after a failure. Which could
be useful for tests
2017-08-16 14:15:50 +02:00
Douwe Maan 0da644072f Merge branch 'malformed-submodule' into 'master'
Handle missing .gitmodules when getting submodule urls

See merge request !13509
2017-08-15 09:00:44 +00:00
Douwe Maan a64760d6d0 Merge branch 'gitaly-404-commit-list-files' into 'master'
Migrate `Git::Repository.ls_files` to Gitaly

Closes gitaly#404

See merge request !13302
2017-08-14 15:44:36 +00:00
Jacob Vosmaer d9b6fd4fba Handle missing .gitmodules when getting submodule urls 2017-08-14 10:53:02 +02:00
Rémy Coutable 1b413bd62f Enable Timecop safe mode
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-11 14:53:17 +02:00
Robert Speicher c8b802471b Enable the RSpec/HookArgument cop and auto-correct offenses 2017-08-10 19:29:42 -04:00
Kim "BKC" Carlbäcker 7b10885046 Migrate Git::Repository.ls_files to Gitaly 2017-08-10 16:10:47 +02:00
Rémy Coutable c946ee1282
Enable the Layout/SpaceBeforeBlockBraces cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-09 11:52:22 +02:00
Alejandro Rodríguez 3ce6f03f14 Incorporate Gitaly's CommitService.FindCommit RPC 2017-08-07 23:33:43 -04:00
Alejandro Rodríguez e363fbf71a Move `deltas` and `diff_from_parents` logic to Gitlab::Git::Commit
This helps keep the abstraction layers simpler, and also keep the
interface of those methods consistent, in case of implementation
changes.
2017-08-07 23:33:40 -04:00
Alejandro Rodríguez c21ae07e33 Refactor Gitlab::Git::Commit to include a repository 2017-08-07 22:34:34 -04:00
Douwe Maan 942bd5b411 Merge branch 'blob-batch-methods' into 'master'
Add Gitlab::Git::Blob.batch method

See merge request !13225
2017-08-07 19:57:25 +00:00
Jacob Vosmaer 29a1c5a126 Rename 'limit' to 'blob_size_limit' 2017-08-07 16:26:50 +02:00
Douwe Maan 727b6d16e5 Merge branch 'master' into 'bvl-nfs-circuitbreaker'
# Conflicts:
#   app/models/repository.rb
#   spec/models/repository_spec.rb
2017-08-07 09:13:10 +00:00
Sean McGivern 9b21668663 Merge branch 'gitaly-renames-annotations' into 'master'
Gitaly deletions and annotations

See merge request !13280
2017-08-07 08:40:53 +00:00
Bob Van Landuyt 4b34720c0c Use ruby's `File.stat` to check storage availability 2017-08-04 15:38:50 +02:00
Bob Van Landuyt 0dd4c306ca Only track accessibility once 2017-08-04 15:38:50 +02:00
Bob Van Landuyt 022c38e63e Use `keys` instead of `scan_each` 2017-08-04 15:38:49 +02:00
Bob Van Landuyt 3899d07f9e Move hostname to Gitlab::Environment 2017-08-04 15:38:49 +02:00
Bob Van Landuyt 0fa94a0ddd Make sure the check works for paths with spaces. 2017-08-04 15:38:49 +02:00
Bob Van Landuyt 3598e60bf2 Add a Circuitbreaker for storage paths 2017-08-04 15:38:48 +02:00
Ahmad Sherif 03440eed20 Migrate blame loading to Gitaly
Closes gitaly#421
2017-08-03 19:20:46 +02:00
Jacob Vosmaer 3a8f4a3460 Remove unnecessary 'raw' alias 2017-08-03 15:52:14 +02:00
Jacob Vosmaer 29a07fd3a1 Rename 'commits_between' to 'rugged_commits_between' 2017-08-03 15:48:10 +02:00
Ahmad Sherif 215e0911e5 Migrate Gitlab::Git::Repository#count_commits to Gitaly
Closes gitaly#415
2017-08-02 00:33:04 +02:00
Sean McGivern 7a2509ea1f Merge branch 'blob-limit-test' into 'master'
Fix bug in blob test

See merge request !13224
2017-08-01 12:53:57 +00:00
Jacob Vosmaer f3569a25e4 Fix bug in blob test 2017-08-01 13:53:32 +02:00
Jacob Vosmaer 5e20e448ce Add Gitlab::Git::Blob.batch method 2017-08-01 13:49:57 +02:00
Jacob Vosmaer 67de82cf5f Add option to use CommitLanguages RPC 2017-08-01 10:48:46 +02:00
Alejandro Rodríguez 8e3f2ecfa9 Incorporate RefsService.FindAllBranches Gitaly RPC 2017-07-27 15:40:54 -04:00
Alejandro Rodríguez 8065adcc1e Improve Gitlab::Git::Repository specs for #branches 2017-07-27 15:39:31 -04:00
Alejandro Rodríguez 432bb22308 Remove unused Gitlab::Git operations 2017-07-27 15:39:31 -04:00
Ahmad Sherif cd5ae5cb2b Migrate Repository#tags to Gitaly
Closes gitaly#411
2017-07-27 20:07:40 +02:00
Rémy Coutable cddc5cacfb Use described_class when possible
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Rémy Coutable ddccd24c13 Remove superfluous lib: true, type: redis, service: true, models: true, services: true, no_db: true, api: true
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Rémy Coutable 8efc884166 Merge branch 'gitaly-tree-entries' into 'master'
Incorporate CommitService.GetTreeEntries Gitaly call

Closes gitaly#372

See merge request !12941
2017-07-21 15:47:36 +00:00
Ahmad Sherif b043100b65 Migrate Gitlab::Git::Commit.find_all to Gitaly
Closes gitaly#396
2017-07-20 22:03:55 +02:00
Alejandro Rodríguez 9eb5cdd73f Incorporate CommitService.GetTreeEntries Gitaly call 2017-07-20 12:47:00 -04:00
Ahmad Sherif ef2b81adb4 Migrate DiffCollection limiting logic to Gitaly 2017-07-19 18:05:22 +02:00
Alejandro Rodríguez 25b01b4c85 Incorporate Gitaly's Commits#between RPC 2017-07-18 16:20:27 -04:00
Alejandro Rodríguez 90f8feae46 Adapt to new Gitaly commit message format 2017-07-18 16:11:44 -04:00
Andrew Newdigate a89f18bf2c Renamed Gitaly services 2017-07-18 07:59:36 +00:00
Sean McGivern 8b31ecd3d9 Merge branch 'remove-git-search-files' into 'master'
Remove Repository#search_files

See merge request !12879
2017-07-17 11:13:49 +00:00
Jacob Vosmaer 682b328787 Remove Repository#search_files 2017-07-14 18:17:31 +02:00
Jacob Vosmaer b304fd790b Make commit lookups explicit 2017-07-14 17:08:53 +02:00
Jacob Vosmaer 08b462b9b0 Remove deprecated #heads method 2017-07-14 15:11:42 +02:00
Sean McGivern 34da5a5de4 Merge branch 'gitlab-git-repository-log' into 'master'
Gitlab::Git shuffling and Gitaly annotations

See merge request !12849
2017-07-14 11:09:11 +00:00
Jacob Vosmaer b2ecf0aa35 Change Git::Repository#log to return Commits 2017-07-13 14:54:21 +02:00
Rémy Coutable a97208dde7 Merge branch 'bvl-enable-features-in-test' into 'master'
Enable all feature flags by default in specs

See merge request !12832
2017-07-13 12:24:31 +00:00
Bob Van Landuyt 3ee48e422d Enable all feature flags by default in specs
Otherwise some features would go untested in non-specific contexts

I did need to disable the
`gitlab_git_diff_size_limit_increase`-feature in some specs since we
depend on diffs being expandable while the file we are testing on is
smaller than the increased limit.
2017-07-13 13:00:34 +02:00
Sean McGivern e0ce648d5c Merge branch 'lib-git-gitaly' into 'master'
Add Gitaly notes to Gitlab::Git, delete diff options

See merge request !12814
2017-07-13 09:32:36 +00:00
Jacob Vosmaer 0b0e89ef7b Try to eliminate unused diff options 2017-07-12 18:28:29 +02:00
blackst0ne 2c8700c01e Replace 'browse_files.feature' spinach test with an rspec analog 2017-07-12 23:45:42 +11:00
Jacob Vosmaer 06b9449224 Add gitaly_git_blob_raw feature 2017-07-07 18:33:59 +02:00
Robert Speicher 1dab640357 Merge branch 'feature/migrate-commit-count-to-gitaly' into 'master'
Migrate Gitlab::Git::Repository#commit_count to Gitaly

Closes gitaly#355

See merge request !12688
2017-07-07 15:21:05 +00:00
Ahmad Sherif c393d88df3 Migrate Gitlab::Git::Repository#commit_count to Gitaly
Closes gitaly#355
2017-07-07 13:47:34 +02:00
Sean McGivern 9e4aef263a Merge branch 'gitaly-submodule-url-for' into 'master'
Migrate #submodule_url_for to Gitaly

See merge request !12629
2017-07-05 11:25:39 +00:00
Jacob Vosmaer b67d1d64cc Migrate #submodule_url_for to Gitaly 2017-07-05 11:09:03 +02:00
Jacob Vosmaer ec35a9e860 Remove unnecessary clear_stubs calls 2017-07-04 13:02:11 +02:00
Jacob Vosmaer 8a62f304ef Add a UTF-8 encoding matcher 2017-06-30 14:32:42 +02:00
Jacob Vosmaer 7648f11381 Remove unnecessary contexts 2017-06-30 14:32:42 +02:00
Alejandro Rodríguez f4e6aba1bb Set the GL_REPOSITORY env variable on Gitlab::Git::Hook 2017-06-29 15:22:40 -04:00
Jacob Vosmaer d3bcf8ac2a Fix gitaly ref encoding bugs 2017-06-28 16:15:59 +02:00
Sean McGivern 5dd6d9a9ec Merge branch 'submodules-private' into 'master'
Make Gitlab::Git::Repository#submodules private

See merge request !12479
2017-06-28 09:25:45 +00:00
Jacob Vosmaer cf131bf713 Make Gitlab::Ggit::Repository#submodules private 2017-06-27 16:03:35 +02:00
Jacob Vosmaer 43c3a65062 Remove 'contains' option from Commit.find_all 2017-06-27 12:38:58 +02:00
Jacob Vosmaer 144e37c667 Remove Gitlab::Git::Repository#find_all 2017-06-27 12:30:51 +02:00
Robert Speicher 826d5b7b51 Merge branch 'fix/properly-encode-gitaly-diffs' into 'master'
Encode Gitaly diff patches properly

See merge request !12368
2017-06-22 16:50:30 +00:00
Ahmad Sherif 5b092d21cc Encode Gitaly diff patches properly 2017-06-22 03:12:23 +02:00
Robert Speicher f85d0a0024 Merge branch 'feature/migrate-blob-find-to-gitaly' into 'master'
Migrate Gitlab::Git::Blob.find to Gitaly

See merge request !12104
2017-06-22 01:00:30 +00:00
Ahmad Sherif 0284f01716 Migrate Gitlab::Git::Blob.find to Gitaly 2017-06-21 17:31:20 +02:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Rémy Coutable 2a39280db0 Merge branch 'moved-submodules' into 'master'
repository: index submodules by path

See merge request !10798
2017-06-19 17:51:55 +00:00
David Turner b30c16aa32 repository: index submodules by path
Submodules have a name in the configuration, but this name is simply
the path at which the submodule was initially checked in (by default
-- the name is totally arbitrary).  If a submodule is moved, it
retains its original name, but its path changes.  Since we discover
submodules inside trees, we have their path but not necessarily their
name.

Make the submodules() function return the submodule hash indexed by
path rather than name, so that renamed submodules can be looked up.

Signed-off-by: David Turner <novalis@novalis.org>
2017-06-16 14:37:13 -04:00
Sean McGivern 9a73b634ab Add table for files in merge request diffs
This adds an ID-less table containing one row per file, per merge request
diff. It has a column for each attribute on Gitlab::Git::Diff that is serialised
currently, with the advantage that we can easily query the attributes of this
new table.

It does not migrate existing data, so we have fallback code when the legacy
st_diffs column is present instead. For a merge request diff to be valid, it
should have at most one of:

* Rows in this new table, with the correct merge_request_diff_id.
* A non-NULL st_diffs column.

It may have neither, if the diff is empty.
2017-06-16 18:30:01 +01:00
Robert Speicher a6ec5121f0 Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
Douwe Maan ffbbd4112e Move diffable? method from Repository to Diff::File 2017-06-08 09:32:57 -05:00
Douwe Maan 3a5d375e49 Fix Diff::Position#diff_file for positions on straight diffs 2017-06-06 14:48:05 -05:00
Douwe Maan 07e7ce31e3 Merge branch '31983-increase-merge-request-diff-file-size-limit-for-default-toggle-opening' into 'master'
Increase diff limits to 100 KB for collapse and 200 KB overall

Closes #31983

See merge request !11875
2017-06-05 13:58:54 +00:00
Robert Speicher 993412f9de Merge branch 'fix/use-new-gitaly-commit-diff-rpc' into 'master'
Use the new Gitaly CommitDiff RPC

See merge request !11826
2017-06-02 19:39:02 +00:00
Sean McGivern 1d3c33b57e Increase diff limits to 100 KB for collapse and 200 KB overall
This is controlled with the feature flag gitlab_git_diff_size_limit_increase.
Both of these limits were basically picked arbitrarily in the first place;
disabling the feature flag reverts to the old limits.
2017-06-02 19:37:09 +01:00
Ahmad Sherif 4d1e987ec3 Use the new Gitaly CommitDiff RPC 2017-06-02 18:33:18 +02:00
Bob Van Landuyt e564fe971f Rename `Gitlab::Git::EncodingHelper` to `Gitlab::EncodingHelper` 2017-06-01 21:21:14 +00:00
Sean McGivern 04251829ba Merge branch 'dm-collapsed-blob' into 'master'
Consistent diff and blob size limit names

See merge request !11776
2017-06-01 09:10:53 +00:00
Douwe Maan 04cf618b6f Change no_limits to limits 2017-05-31 14:41:25 -05:00
Douwe Maan ce869e3964 Fix Diff#too_large? and specs 2017-05-30 21:48:30 -05:00
Douwe Maan 0c7dd30c78 Make .gitmodules parsing more resilient to syntax errors 2017-05-30 16:19:36 -05:00
Bob Van Landuyt 33aed43e9d Avoid crash when trying to parse string with invalid UTF-8 sequence 2017-05-30 15:05:52 +00:00
Douwe Maan aed0387f97 Consistent diff and blob size limit names 2017-05-29 17:02:02 -05:00
Jacob Vosmaer fcdc427972 Add test that shows DiffCollection restart bug 2017-05-23 18:45:58 +02:00
Douwe Maan 6319ca271c Merge branch 'gitaly-local-branches' into 'master'
Incorporate Gitaly's local_branches operation into repo code

Closes #27379

See merge request !10059
2017-05-18 14:22:41 +00:00
Alejandro Rodríguez 925945f01b Incorporate Gitaly's local_branches operation into repo code 2017-05-17 18:12:10 -04:00
Alejandro Rodríguez cf09c826a5 Re-enable gitaly migration for ref_name_for_sha after bugfixes 2017-05-16 11:43:37 -04:00
Rémy Coutable 3db37e0562 Enable the Style/TrailingCommaInArguments cop
Use the EnforcedStyleForMultiline: no_comma option.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-05-10 18:25:45 +02:00
Rémy Coutable d40e1f547e Enable the Style/TrailingCommaInLiteral cop
Use the EnforcedStyleForMultiline: no_comma option.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-05-10 18:25:45 +02:00
Timothy Andrew b44eaf8e07 Sort the network graph both by commit date and topographically.
- Previously, we sorted commits by date, which seemed to work okay.

- The one edge case where this failed was when multiple commits have the same
  commit date (for example: when a range of commits are cherry picked with a
  single command, they all have the same commit date [and different author
  dates]).

- Commits with the same commit date would be sorted arbitrarily, and usually
  break the network graph.

- This commit solves the problem by both sorting by date, and by sorting
  topographically (parents aren't displayed until all their children are
  displayed)

- Include review comments from @adamniedzielski

A more detailed explanation is present here:
https://gitlab.com/gitlab-org/gitlab-ce/issues/30973#note_28706230
2017-05-04 04:21:12 +00:00
Douwe Maan 185fd98fd4 Merge branch 'fix-gitaly-not-found' into 'master'
Re-enable ref operations with gitaly after not-found fix

See merge request !10773
2017-05-02 22:32:34 +00:00
Douwe Maan 2a73f0a638 Merge branch 'rs-described_class-cop-2' into 'master'
Enable `RSpec/DescribedClass` cop and correct violations

See merge request !10930
2017-05-02 22:30:30 +00:00
Alejandro Rodríguez 5e0e5801f1 Re-enable ref operations with gitaly after not-found fix 2017-05-02 17:17:58 -03:00
Robert Speicher d49768296c Auto-correct `RSpec/DescribedClass` violations 2017-05-01 11:13:33 -04:00
Kim "BKC" Carlbäcker a998710a3b Fix RSpec 2017-04-28 13:07:54 +02:00
Timothy Andrew a7e67604b3 Fix ordering of commits in the network graph.
- We upgraded `rugged` to 0.25.1.1 in !10286 for %9.1

- Prior to this upgrade, the default sort order for commits returned by
  `Gitlab::Git::Repository#find_commits` was `Rugged::SORT_DATE`, which the
  graph relied on.

- While upgrading `rugged`, the MR also changed this default to
  `Rugged::SORT_NONE`, which broke commit ordering in the graph.

- This commit adds an option to `Gitlab::Git::Repository#find_commits` to sort
  by date, and changes the graph builder `Network::Graph` so it explictly
  requests the `:date` sort order
2017-04-27 13:09:54 +00:00
James Lopez 71b6a4ba85 Return empty string on UTF8 conversion with U_STRING_NOT_TERMINATED_WARNING error 2017-04-20 16:10:33 +02:00
Douwe Maan d170133bde Refactor changing files in web UI 2017-04-20 00:37:44 +00:00
Douwe Maan d6f49b85f1 Fix specs 2017-04-17 18:31:23 -05:00
Rémy Coutable c43f7d4713 Merge branch 'gitaly-testing' into 'master'
Setup and run a Gitaly server for testing if GitalyClient is enabled

See merge request !10298
2017-04-12 09:25:09 +00:00
Alejandro Rodríguez d6cc8feb6c Setup and run a Gitaly server for testing if GitalyClient is enabled 2017-04-11 16:00:44 -03:00
Rémy Coutable ae88355bb8 Retrieve Git-specific env in Gitlab::Git::RevList and add a new #new_refs method
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-10 16:10:18 +02:00
Rémy Coutable cb20cfa244 Retrieve Git-specific env in Gitlab::Git::Repository#rugged
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-10 16:10:18 +02:00
Rémy Coutable 05aa038c42 Add a Gitlab::Git::Env to store Git-specific env thread-safely
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-10 16:10:18 +02:00
Alejandro Rodríguez 267cd3e359 Incorporate Gitaly client for refs service 2017-04-04 16:53:44 +02:00
mhasbini ed5d59d4c4 Fix symlink icon in project tree 2017-04-02 14:42:37 +03:00
Sean McGivern 53819c5ac6 Support >1 path in Gitlab::Git::Repository#log
This is analogous to `git log -- foo bar baz`, but not the same as
`Gitlab::Git::Repository#log(path: 'foo bar baz')`, which would run `git
log -- 'foo bar baz'`.
2017-03-30 10:21:19 +01:00
Robert Speicher def164e761 Fix RSpec/DescribeSymbol cop violations 2017-03-24 19:04:03 -04:00
Robert Speicher 5409a3c5b7 Merge branch 'feature/use-gitaly-for-commit-show' into 'master'
Use Gitaly for CommitController#show

See merge request !9629
2017-03-17 17:41:44 +00:00
Mark Fletcher 4597654079 Fix archive prefix bug for refs containing dots 2017-03-16 21:04:58 +05:30
Ahmad Sherif c0a4f527db Use Gitaly for CommitController#show 2017-03-15 12:52:11 +02:00
Rémy Coutable 464ca33747
Allow to override GITLAB_GIT_TEST_REPO_URL to specify a different gitlab-git-test repo
We will set this to the dev mirror in GitLab CE and EE on dev.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-03-14 18:30:53 +01:00
Oswaldo Ferreira d13451cd49 Returns correct header data for commits endpoint 2017-03-07 22:56:31 -03:00
George Andrinopoulos c46f933bb7 Fix pagination headers for repository commits api endpoint 2017-03-07 22:56:31 -03:00
Mark Fletcher 3ac54d22b9 Ensure archive download is only one directory deep 2017-03-02 10:30:24 +05:30
Robert Speicher cecfcc2edd Merge branch '23062-allow-git-log-to-accept-follow-and-skip' into 'master'
Make Git history follow renames again by performing the --skip in Ruby

Closes #23062

See merge request !9314
2017-02-25 19:58:05 +00:00
Douwe Maan a530e9da35 Address review 2017-02-24 09:55:01 -06:00
Douwe Maan 0625af3bcb Consistently create, update, and delete files, taking CRLF settings into account 2017-02-24 09:55:01 -06:00
Rémy Coutable 9720bcd83d Optimize a bit Gitlab::Git::Repository#log_by_shell and its specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-02-23 19:06:00 +01:00
Rémy Coutable 3eb0354061 Make Git history follow renames again by performing the --skip in Ruby
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>
2017-02-23 19:06:00 +01:00
Douwe Maan 1fe7501b49 Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
2017-02-23 09:33:05 -06:00
Douwe Maan 7d4b52b27d Enable Style/WordArray 2017-02-23 09:32:41 -06:00
Douwe Maan 206953a430 Prefer leading style for Style/DotPosition 2017-02-23 09:32:22 -06:00
Douwe Maan 7ea641b6d0 Enable Style/ColonMethodCall 2017-02-23 09:31:57 -06:00
Douwe Maan c10064aad5 Enable Style/SpaceInsideBrackets 2017-02-23 09:31:56 -06:00
Robert Speicher 80a6d2fda2 Use `:empty_project` where possible throughout spec/lib 2017-01-25 12:25:42 -05:00
Robert Speicher 2e20a71d21 Ensure internal Gitlab::Git references use the namespace 2017-01-04 19:09:29 -05:00
Robert Speicher a00578ce5c Absorb gitlab_git 2017-01-04 19:09:28 -05:00
Rémy Coutable 212967aefb
Reject blank environment vcariables in Gitlab::Git::RevList
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-20 09:45:37 +01:00
Timothy Andrew e394d2872a Implement final review comments from @rymai.
- `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.
2016-12-16 23:32:25 +05:30
Timothy Andrew 3e1442766f Implement review comments from @dbalexandre.
- 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.
2016-12-16 23:32:25 +05:30
Timothy Andrew a2b39feb1a Validate environment variables in `Gitlab::Git::RevList`
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.
2016-12-16 23:32:25 +05:30
Grzegorz Bizon c7b31e4029 Enable some Rubocop cops related to new lines 2016-08-03 12:02:41 +02:00
Timothy Andrew eb16e1e3c2 Improve the error message displayed when branch creation fails.
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.
2016-07-05 11:05:16 +05:30
Dmitriy Zaporozhets 4f2d2c90f7 Move Gitlab::Git out of gitlab core 2013-04-27 23:50:17 +03:00
Dmitriy Zaporozhets 211c433cd8 Gitlab::Git::Stats specs 2013-04-16 16:39:48 +03:00
Dmitriy Zaporozhets be41d0e1bf Gitlab::Git::Diff specs 2013-04-16 16:30:16 +03:00
Dmitriy Zaporozhets c3bbbff673 specs for repository tag_names, branch_names 2013-04-03 21:21:24 +03:00
Dmitriy Zaporozhets f8a4a76048 decorate commits in Gitlab::Git::repository with valid class 2013-04-03 21:17:50 +03:00
Dmitriy Zaporozhets e91ff84df7 keep same dir structure for specs as in lib/ 2013-04-03 21:09:07 +03:00