Commit Graph

717 Commits

Author SHA1 Message Date
Sean McGivern e2aa2177a7 Merge branch 'zj-improve-gitaly-pb' into 'master'
Show what RPC is called in the performance bar

See merge request gitlab-org/gitlab-ce!23140
2018-11-20 06:42:49 +00:00
Zeger-Jan van de Weg 4ca5eadddb
Remove duplicate tests for Gitaly
The disabling of Gitaly was basically stubbing `Feature.enabled?` call,
which was never triggered.
2018-11-19 14:40:53 +01:00
Nick Thomas f1bc7b6eb5
SSH public-key authentication for push mirroring 2018-11-19 11:46:39 +00:00
Sean McGivern 85ec04eaaa Merge branch 'gt-fix-typos-in-lib' into 'master'
Fix typos in lib

See merge request gitlab-org/gitlab-ce!23106
2018-11-16 10:32:31 +00:00
George Tsiolis 566ba126f5 Fix typos in lib 2018-11-15 12:15:43 +02:00
Oswaldo Ferreira 039df0267e Avoid Gitaly RPC errors when fetching diff stats 2018-11-14 17:33:30 -02:00
Bob Van Landuyt 6fbdc5ed52 Apply patches when creating MR via email
This allows users to add patches as attachments to merge request
created via email.

When an email to create a merge request is sent, all the attachments
ending in `.patch` will be applied to the branch specified in the
subject of the email. If the branch did not exist, it will be created
from the HEAD of the repository.

When the patches could not be applied, the error message will be
replied to the user.

The patches can have a maximum combined size of 2MB for now.
2018-11-07 16:27:55 +01:00
Nick Thomas 668e5d63fa
Stop Repository#fetch_remote from using Gitlab::Shell
This indirection doesn't provide any value, so remove it
2018-11-06 12:42:00 +00:00
Achilleas Pipinellis 7f47e13218 Merge branch 'gt-update-typos-in-comments-and-specs' into 'master'
Fix typos in comments and specs

See merge request gitlab-org/gitlab-ce!22683
2018-11-01 10:34:23 +00:00
George Tsiolis 733ae94921 Fix typos in comments and specs 2018-11-01 08:59:20 +02:00
Douwe Maan 571e651b21 Merge branch 'add-language-param-to-highlight' into 'master'
Add language param to highlight

See merge request gitlab-org/gitlab-ce!21584
2018-10-30 20:44:03 +00:00
Bob Van Landuyt 81f5955eb6 Move Repository#wrapped_gitaly_errors into concern
Having this in a concern allows us to reuse it for different single
purpose classes that call out to git without going through the
repository every time.
2018-10-30 15:53:46 +01:00
Mark Chao 6f03784857 Add spec for Gitlab::Git::Repository#attributes
seed_helper changed because testing requires attributes file in repo,
but repo was not a real git repo but instead faked.
2018-10-30 15:44:55 +08:00
Tiago Botelho 084a8b6101
Adds tracing messages for slow git pushes
Whenever a git push takes more than 50 seconds the user
will receive a trace from each check performed along with
their timings
2018-10-25 10:10:45 +01:00
Nick Thomas c5bff77ea4
Remove a dependency on gitlab-gollum-lib
Inlining this code allows us to remove a dependency on gitlab_grit in
gitlab-ce. We can't stop maintaining gitlab_grit yet, since gitaly-ruby
still depends on this gem, but it moves us a step closer.
2018-10-16 12:53:30 +01:00
Zeger-Jan van de Weg 399056ed78 Remove dependencies on Linguist
This saves about 128 MB of baseline RAM usage per Unicorn and
Sidekiq process (!).

Linguist wasn't detecting languages anymore from CE/EE since
9ae8b57467. However, Linguist::BlobHelper
was still being depended on by BlobLike and others.

This removes the Linguist gem, given it isn't required anymore.
EscapeUtils were pulled in as dependency, but given Banzai depends on
it, it is now added explicitly.

Previously, Linguist was used to detect the best ACE mode. Instead,
we rely on ACE to guess the best mode based on the file extension.
2018-10-12 17:17:30 -07:00
Zeger-Jan van de Weg 30b4ce940d
Remove Git circuit breaker
Was introduced in the time that GitLab still used NFS, which is not
required anymore in most cases. By removing this, the API it calls will
return empty responses. This interface has to be removed in the next
major release, expected to be 12.0.
2018-10-10 09:08:18 +02:00
Kamil Trzciński 84c4e920cd Merge branch 'master' into 'feature/gb/pipeline-only-except-with-modified-paths'
# Conflicts:
#   app/models/ci/pipeline.rb
2018-10-04 16:52:48 +00:00
Alejandro Rodríguez a99bf447a2 Remove Gitlab::Git::Repository#rugged and Gollum code
Cleanup code, and refactor tests that still use Rugged. After this, there should
be no Rugged code that access the instance's repositories on non-test
environments. There is still some rugged code for other tasks like the
repository import task, but since it doesn't access any repository storage path
it can stay.
2018-10-02 16:34:28 -03:00
Grzegorz Bizon 1c4187e38e Treat nil git push revisons as a blank Git SHA value 2018-10-02 13:01:55 +02:00
Grzegorz Bizon 9bad9b0a68 Improve specs for git push class
This helps to prevent problems with off-by-one commmit problem in
`Gitlab::Git::Push#modified_paths`.
2018-09-28 15:38:36 +02:00
Grzegorz Bizon 419d8cc7a2 Calculate modified paths of a git push operation 2018-09-28 15:13:04 +02:00
Grzegorz Bizon 4abba28944 Add specs for extracted git push class 2018-09-28 14:46:22 +02:00
Michael Kozono a54a5d9f39 Use `Gitlab::SafeRequestStore` in more places
Even if it doesn’t save lines of code, since people will tend to use
code they’ve seen. And `SafeRequestStore` is safer since you
don’t have to remember to check `RequestStore.active?`.
2018-09-24 12:11:27 -07:00
Oswaldo Ferreira 5dce096cf8 Use standalone diff stats RPC on every comparison view 2018-09-19 12:26:28 +00:00
Douwe Maan bff85a4b1c Merge branch 'osw-gitaly-diff-stats-client' into 'master'
Add Gitaly diff stats RPC client

See merge request gitlab-org/gitlab-ce!21732
2018-09-17 16:29:42 +00:00
Oswaldo Ferreira c9d6c02f15 Add Gitaly diff stats RPC client
This adds a basic interface to fetch diff statistics given two SHAs.
It's a requirement for #49399 #20282 and #19232.
2018-09-17 12:27:01 -03:00
Nick Thomas fc0194b589 Resolve "Add functionality to change what email address online actions commit using" 2018-09-14 09:52:09 +00:00
Douglas Barbosa Alexandre 5d8e41fd35
Update Gitlay server version to 0.121.0 2018-09-13 15:36:14 -03:00
Alejandro Rodríguez d3c5b07962 Remove Rugged and shell code from Gitlab::Git 2018-09-12 12:32:32 -03:00
Douglas Barbosa Alexandre 42c061781a
Encode remote root ref 2018-09-07 08:45:37 -03:00
Douglas Barbosa Alexandre 460badd8cc
Add Gitlab::Git::Repository#find_remote_root_ref 2018-09-06 16:01:48 -03:00
Michael Kozono 51dc249f44 Fix typo 2018-08-18 00:18:58 -07:00
Bob Van Landuyt 7466df872c Get the `merge-base` of 2 refs trough the API
This adds an endpoint to get the common ancestor of 2 refs from the API.
2018-08-13 11:58:54 +02:00
Alejandro Rodríguez 01de2b5df8 Refactor gitlab:import:repos task to remove direct disk access 2018-07-31 16:28:44 -04:00
Stan Hu c8ff6b7c73 Use limit parameter to retrieve Wikis from Gitaly
Without this parameter, every load of a Wiki page will load all the Wiki pages
in the repository for the sidebar. This is a significant performance penalty
that can significant slow the display of all Wiki pages.

Relates to #40101
2018-07-24 15:36:31 -07:00
Alejandro Rodríguez fa1ea656f7 Migrate add_remote, remove_remote, fetch_internal_remote to gitaly 2018-07-19 15:07:37 -04:00
Alejandro Rodríguez 68b1e5a97c Incorporate Gitaly's RefService.FindAllRemoteBranches RPC 2018-07-18 16:48:47 -04:00
Zeger-Jan van de Weg 9348efc6ba
Client implementation for Repository#new_commits
After trying to remove the whole method in
8f69014af2902d8d53fe931268bec60f6858f160, this is a more gentle
approach to the method. :)

Prior to this change, new commit detection wasn't implemented in Gitaly,
this was done through: https://gitlab.com/gitlab-org/gitaly/merge_requests/779

As the new implemented got moved around a bit, the whole RevList class
got removed.

Part of https://gitlab.com/gitlab-org/gitaly/issues/1233
2018-07-18 14:46:27 +02:00
Jacob Vosmaer (GitLab) 5c651daa97 Remove unreachable Git code 2018-07-18 11:12:57 +00:00
Jacob Vosmaer (GitLab) 37eca76583 Remove Repository#lookup and unreachable rugged code 2018-07-16 10:34:31 +00:00
Yorick Peterse 9451c80ac9 Merge branch 'sh-fix-stderr-pipe-consumption' into 'master'
Avoid process deadlock in popen by consuming input pipes

Closes gitlab-ee#6895

See merge request gitlab-org/gitlab-ce!20600
2018-07-13 13:14:34 +00:00
Stan Hu fd392cd725 Avoid process deadlock in popen by consuming input pipes
A process that spews a lot of output to stderr or stdout could stall out
due to the pipe buffer being full. As described in https://bugs.ruby-lang.org/issues/9082,
we can use the trick used in Ruby's capture3 function to read the pipes in separate
threads.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/6895
2018-07-12 16:21:30 -07:00
Jacob Vosmaer 40ed88b784 whitespace 2018-07-12 15:35:24 +02:00
Jacob Vosmaer d1d7144b96 Make more ref RPC's mandatory 2018-07-12 15:12:00 +02:00
Jacob Vosmaer (GitLab) 62ffad0802 Remove Repository#path memoization 2018-07-12 09:49:25 +00:00
Jacob Vosmaer 723f74d49d Remove last flags from Blob and Workhorse 2018-07-11 12:59:15 +02:00
Jacob Vosmaer a4e75e7a83 Use Gitaly for fetches and creating bundles 2018-07-09 12:50:17 +02:00
Jacob Vosmaer (GitLab) 3082b7d1c2 Make blob and other RPC's mandatory 2018-07-09 10:02:02 +00:00
Jacob Vosmaer ff112ce641 Add Repository#set_config and #delete_config 2018-07-06 12:06:54 +02:00
Jacob Vosmaer 201802f723 Remove more feature flags 2018-07-03 17:39:08 +02:00
Jacob Vosmaer (GitLab) 15aadc665f Make OperationService RPC's mandatory 2018-07-03 09:12:03 +00:00
Douwe Maan e28896ce0d Merge branch 'zj-find-all-commits' into 'master'
FindAllCommits mandatory

Closes gitaly#326

See merge request gitlab-org/gitlab-ce!20242
2018-06-28 13:11:00 +00:00
Douwe Maan 37b1922237 Merge branch 'zj-commits-between-mandatory' into 'master'
Commits between in Gitaly only

Closes gitaly#315

See merge request gitlab-org/gitlab-ce!20239
2018-06-28 13:10:07 +00:00
Zeger-Jan van de Weg ec78d29a6e
FindAllCommits mandatory
Closes https://gitlab.com/gitlab-org/gitaly/issues/326
2018-06-28 13:42:10 +02:00
Zeger-Jan van de Weg f369da063f
Commits between in Gitaly only
Prior to this change, most the commits counted were done through Gitaly.
This removes the last point where this wasn't the case.

This makes the `rugged_count_commits` method obsolete, with its tests.

Closes https://gitlab.com/gitlab-org/gitaly/issues/315
2018-06-28 12:09:20 +02:00
Jacob Vosmaer f4d6834786 Make Gitaly signature RPC's mandatory 2018-06-27 14:32:09 +02:00
Douwe Maan 77fe416681 Merge branch 'zj-create-from-bundle-mandatory' into 'master'
Moves CreateFromBundle RPC to mandatory

Closes gitaly#944

See merge request gitlab-org/gitlab-ce!20144
2018-06-25 15:29:57 +00:00
Douwe Maan 246ce5b5f9 Merge branch 'zj-write-config' into 'master'
Write Config is mandatory

Closes gitaly#879

See merge request gitlab-org/gitlab-ce!20146
2018-06-25 15:27:41 +00:00
Zeger-Jan van de Weg 29b4d657be
Moves another RPC to mandatory
This specific one isn't used on most machines, therefor low risk.

Closes https://gitlab.com/gitlab-org/gitaly/issues/944
2018-06-25 15:55:22 +02:00
Zeger-Jan van de Weg 0855478726
Write Config is mandatory
Closes https://gitlab.com/gitlab-org/gitaly/issues/879
2018-06-25 15:08:20 +02:00
Zeger-Jan van de Weg e91b2b5dff
Gitaly tree entry is mandatory
Closes https://gitlab.com/gitlab-org/gitaly/issues/310
2018-06-25 13:48:28 +02:00
Zeger-Jan van de Weg 2ac672280b
Raw changes calculation is Gitaly only now
Closes https://gitlab.com/gitlab-org/gitaly/issues/1138
2018-06-21 10:12:51 +02:00
Douwe Maan c67d8c2478 Merge branch 'zj-lfs-pointers' into 'master'
LFS changes are detected by Gitaly

Closes gitaly#935

See merge request gitlab-org/gitlab-ce!19995
2018-06-20 08:29:47 +00:00
Douwe Maan c0f0ccf222 Merge branch 'zj-force-push-opt-out' into 'master'
Force push is handled by Gitaly now

Closes gitaly#348

See merge request gitlab-org/gitlab-ce!19992
2018-06-19 14:19:18 +00:00
Zeger-Jan van de Weg 64cda7746c
LFS changes are detected by Gitaly
Closes https://gitlab.com/gitlab-org/gitaly/issues/935
2018-06-19 15:59:27 +02:00
Zeger-Jan van de Weg c2cdefd441
Force push is handled by Gitaly now
Closes gitlab-org/gitaly#348
2018-06-19 15:35:17 +02:00
Douwe Maan b0fadeee83 Merge branch 'zj-counting-commits' into 'master'
Counting commits is done by Gitaly

Closes gitaly#382

See merge request gitlab-org/gitlab-ce!19983
2018-06-19 12:45:49 +00:00
Douwe Maan f70c581d1f Merge branch 'zj-linguist-gitaly-mandatory' into 'master'
Move language detection to mandatory

Closes gitaly#732 and gitaly#360

See merge request gitlab-org/gitlab-ce!19985
2018-06-19 09:56:45 +00:00
Zeger-Jan van de Weg c24e39ab88
Counting commits is done by Gitaly
Closes https://gitlab.com/gitlab-org/gitaly/issues/382
2018-06-19 10:37:51 +02:00
Zeger-Jan van de Weg da8419a1ba
License detection happens soley through Gitaly now
Migration: https://gitlab.com/gitlab-org/gitaly/issues/1026

Conflicts:
	lib/gitlab/git/repository.rb
2018-06-19 09:35:15 +02:00
Zeger-Jan van de Weg 9ae8b57467
Move language detection to mandatory
Closes https://gitlab.com/gitlab-org/gitaly/issues/732
Closes https://gitlab.com/gitlab-org/gitaly/issues/360
2018-06-19 09:29:54 +02:00
Jacob Vosmaer (GitLab) 14000a561b Make Gitaly wiki RPC's mandatory 2018-06-18 08:19:11 +00:00
Sean McGivern beba4a1d1c Merge branch 'zj-mandatory-batch' into 'master'
Move Gitaly RPCs to mandatory

Closes gitaly#217, gitaly#389, gitaly#390, gitaly#220, gitaly#376, and gitaly#354

See merge request gitlab-org/gitlab-ce!19759
2018-06-14 12:16:05 +00:00
Zeger-Jan van de Weg 3ed4a1b3aa
HasLocalBranches check is done by Gitaly only
Closes https://gitlab.com/gitlab-org/gitaly/issues/217
2018-06-14 10:31:24 +02:00
Zeger-Jan van de Weg 89ab32c6b2
Branches are fully migrated to Gitaly
Closes: https://gitlab.com/gitlab-org/gitaly/issues/389
2018-06-14 10:25:28 +02:00
Zeger-Jan van de Weg 4fc4600747
Default branch detection happens through Gitaly
Migration: https://gitlab.com/gitlab-org/gitaly/issues/220
2018-06-14 09:56:16 +02:00
Zeger-Jan van de Weg f195a7436d
RawBlame only called through Gitaly
Closes https://gitlab.com/gitlab-org/gitaly/issues/376
2018-06-13 16:44:59 +02:00
Zeger-Jan van de Weg e4a9b0771a
ListCommitByOid isn't called with an empty batch
Batching commits for performance improvements, might lead to empty
batches being used. This isn't the case yet, but to guard against this
in future cases, a guard clause is added.
2018-06-13 15:23:34 +02:00
Douwe Maan 8b0d2283d7 Merge branch 'gitaly-disk-access-3' into 'master'
Find and mark more Git disk access locations, part 2

See merge request gitlab-org/gitlab-ce!19437
2018-06-12 13:32:46 +00:00
Jacob Vosmaer f376347f24 Find and mark more Git disk access locations, part 2 2018-06-12 14:33:37 +02:00
Francisco Javier López ab93f7cc79 Bumping gitlab-gollum-lib and gitlab-gollum-rugged_adapter 2018-06-12 12:31:10 +00:00
Jacob Vosmaer (GitLab) ea8dc10772 Don't use Gitlab::Utils.nlbr in Gitlab::Git 2018-06-11 10:42:09 +00:00
Francisco Javier López 86d39016a2
Moving rev-list lfs options to Lfschanges 2018-06-06 21:55:32 +02:00
Francisco Javier López e8f49b4bee Support LFS objects when creating a project by import 2018-06-06 16:42:18 +00:00
Nick Thomas 65dbead796
Fix repository archive generation when hashed storage is enabled 2018-06-05 20:44:07 +01:00
Jacob Vosmaer (GitLab) a0808df0b6 Find and mark more Git disk access locations 2018-06-05 15:51:14 +00:00
Jacob Vosmaer (GitLab) 3a4ecfd0c9 Prevent Gitaly WriteConfig log noise 2018-06-05 12:55:41 +00:00
Jacob Vosmaer (GitLab) edb9db37ed Add "deny disk access" Gitaly feature (tripswitch) 2018-06-01 11:56:29 +00:00
Kim "BKC" Carlbäcker 0db994fedc Fix encoding error in Gitaly::Commit::TreeEntry 2018-05-30 17:33:17 +02:00
Grzegorz Bizon b113330fab Merge branch 'zj-workhorse-archive-mandatory' into 'master'
Move git archives downloading to Gitaly

See merge request gitlab-org/gitlab-ce!18990
2018-05-21 07:08:58 +00:00
Grzegorz Bizon ad9e00917f Merge branch 'xeodon/gitlab-ce-fix/45743-master-fix-gitaly-delete-refs' into 'master'
Fix error when deleting an empty list of refs

Closes #45743

See merge request gitlab-org/gitlab-ce!19053
2018-05-19 05:42:16 +00:00
Sergey Sinev 100c687cbc Fix error when deleting an empty list of refs
Closes #45743
2018-05-18 20:47:46 -07:00
Robert Speicher 076ab2e8e0 Merge branch 'fix/handle-large-commit-tag-message' into 'master'
Add handling for commit/tags with big messages

See merge request gitlab-org/gitlab-ce!17892
2018-05-18 19:28:25 +00:00
Ahmad Sherif 019f5e2469 Add handling for commit/tags with big messages 2018-05-18 20:51:10 +02:00
Nick Thomas 8bacfbd1cc Merge branch 'zj-calculate-checksum-mandator' into 'master'
Calculating repository checksums executed by Gitaly

Closes gitaly#1105 and #46293

See merge request gitlab-org/gitlab-ce!18907
2018-05-18 15:53:35 +00:00
Zeger-Jan van de Weg 18a8eb96b3
Calculating repository checksums executed by Gitaly
OPT_OUT status has been removed, and alternative implementation removed.
Also checks if the repository exists before executing the checksum RPC
to guard against NotFound errors.

Closes gitlab-org/gitaly#1105
2018-05-18 16:07:29 +02:00
Grzegorz Bizon 48877dfc7e Merge branch 'zj-workhorse-commit-patch-diff' into 'master'
Workhorse to send raw diff and patch for commits

Closes gitaly#1196

See merge request gitlab-org/gitlab-ce!18974
2018-05-17 08:12:33 +00:00
Zeger-Jan van de Weg 94b209b32c
Move git archives downloading to Gitaly 2018-05-17 09:31:50 +02:00
Zeger-Jan van de Weg dfdd881510
Workhorse to send raw diff and patch for commits
Prior to this change, this was done through unicorn. In theory this
could time out. Workhorse has been sending these raw patches and diffs
for a long time and is stable in doing so.

Added bonus is the fact that `Commit#to_patch` can be removed.

`Commit#to_diff` too, which closes
https://gitlab.com/gitlab-org/gitaly/issues/324

Closes https://gitlab.com/gitlab-org/gitaly/issues/1196
2018-05-16 11:52:43 +02:00
Zeger-Jan van de Weg 7fc185ab25
Ref contains oid check done by Gitaly
These two endpoints are in opt-out, and no one noticed. Has been running
on .com for 4 months now and considered stable.

Closes https://gitlab.com/gitlab-org/gitaly/issues/884
2018-05-14 15:55:27 +02:00
Rubén Dávila 5b584a0fd2 Backport some changes from gitlab-ee!5476
The lib/gitlab/git/repository.rb needs to have the same content between
gitlab-ce and gitlab-ee in order to have Gitaly working fine.
2018-05-09 13:20:28 -05:00
Douglas Barbosa Alexandre 17258b37c8
Raise InvalidRepository error for non-valid git repositories 2018-05-07 14:22:16 -03:00
Zeger-Jan van de Weg 713c7fa9a5
Client implementation GetRawChanges
Part of https://gitlab.com/gitlab-org/gitaly/issues/1138
2018-05-07 15:37:49 +02:00
Douwe Maan 9cf4e47341 Merge branch 'security-45689-fix-archive-cache-bug' into 'security-10-7'
Serve archive requests with the correct file in all cases (10.7)

See merge request gitlab/gitlabhq!2376
2018-04-30 15:00:14 -05:00
Zeger-Jan van de Weg ec4423665c
Gitlab::Shell works on shard name, not path
Direct disk access is done through Gitaly now, so the legacy path was
deprecated. This path was used in Gitlab::Shell however. This required
the refactoring in this commit.

Added is the removal of direct path access on the project model, as that
lookup wasn't needed anymore is most cases.

Closes https://gitlab.com/gitlab-org/gitaly/issues/1111
2018-04-25 13:36:22 +02:00
Francisco Javier López c921e686b8 Moved committer and spec. Added some extra code to run hooks or not depending on the options 2018-04-23 10:56:46 +00:00
Francisco Javier López e8a27a67fa Fix Custom hooks are not triggered by UI wiki edit 2018-04-18 17:50:56 +00:00
Stan Hu 74e5ec198c Fix failing ./spec/lib/backup/repository_spec.rb by clearing the memoized value 2018-04-14 15:36:36 -07:00
Stan Hu b1f15dfa42 Memoize Git::Repository#has_visible_content?
This is called repeatedly when viewing a merge request, and this should
improve performance significantly by avoiding shelling out to git every time.

This should help https://gitlab.com/gitlab-com/infrastructure/issues/4027.
2018-04-14 14:37:28 -07:00
Douwe Maan db6854b2cd Merge branch 'backport-of-rd-3429-enabling-maximum-file-size-limit-in-repository-causes-pushes-to-fail' into 'master'
Backport of EE !4989

See merge request gitlab-org/gitlab-ce!18238
2018-04-12 08:46:36 +00:00
Rubén Dávila d28b1dfc46 Backport of EE !4989 2018-04-11 22:05:07 -05:00
Zeger-Jan van de Weg c830b8e3b7
Client implementation for InfoAttributes
Clients can now request the attributes from `$GIT_DIR/info/attributes`
through Gitaly. The Gitaly migration is described in gitlab-org/gitaly#1082.

The parser algorithm was implemented in a way it could handle both file
contents or a File handle, and both were already tested.

Other than that, using the boy scout rule, I've removed a class,
InfoAttributes, as it was delegating everything to the parser and
therefor wasn't really needed in my opinion.
2018-04-11 14:21:27 +02:00
Douglas Barbosa Alexandre 76cd2d7881
Move checksum calculation to Gitlab::Git::Repository 2018-04-06 13:25:07 -03:00
Douglas Barbosa Alexandre 13992ac92e
Checksum calculation is handled by Gitaly when feature is enabled 2018-04-06 13:23:23 -03:00
Stan Hu a18eea8c32 Automatically cleanup stale worktrees and lock files upon a push
git 2.16 will fail badly if there are stale worktrees.

Closes #44115
2018-04-06 08:17:07 -07:00
James Ramsay 07f517d441 Add new repository archive route
Repository archives are always named `<project>-<ref>-<sha>` even if
the ref is a commit. A consequence of always including the sha even
for tags is that packaging a release is more difficult because both
the ref and sha must be known by the packager.

- add `<project>/-/archive/<ref>/<filename>.<format>` route using the
`-` separator to prevent namespace collisions. If the filename is
`<project>-<ref>` or the ref is a sha, the sha will be omitted,
otherwise the default filename will be used.
- deprecate previous archive route `repository/<ref>/archive`
2018-04-06 08:45:17 -04:00
James Ramsay 0b1b9c409d Add option to suppress archive commit sha
Repository archives are always named `<project>-<ref>-<sha>` even if
the ref is a commit. A consequence of always including the sha even
for tags is that packaging a release is more difficult because both
the ref and sha must be known by the packager.

- add append_sha option (defaults true) to provide a method for
toggling this feature.

Support added to GitLab Workhorse by gitlab-org/gitlab-workhorse!232
2018-04-04 16:56:18 -04:00
Sean McGivern c353426650 Merge branch 'fix/use-shard-name-in-gitlab-projects-instead-of-shard-path' into 'master'
Use shard name in Git::GitlabProjects instead of shard path

Closes gitaly#1110

See merge request gitlab-org/gitlab-ce!18015
2018-04-04 09:20:19 +00:00
Douglas Barbosa Alexandre 563d38e81e
Backport Gitlab::Git::Checksum to CE 2018-04-03 15:36:43 -03:00
Ahmad Sherif ddfc661f79 Use shard name in Git::GitlabProjects instead of shard path
Closes gitaly#1110
2018-04-03 16:22:13 +02:00
Stan Hu 6fd1d07cfc Handle CR-LFs properly in .gitmodules file
Any submodule lines that had a CR-LF ending would be ignored by the parser.

Closes gitlab-org/gitlab-ce#2262
2018-03-30 15:23:44 -07:00
Jacob Vosmaer (GitLab) b942462788 Remove support for absolute dirs from Git::Env 2018-03-30 09:19:46 +00:00
Sean McGivern c113b70057 Merge branch 'dm-refs-contains-sha-encoding' into 'master'
Fix listing commit branch/tags that contain special characters

Closes #43212

See merge request gitlab-org/gitlab-ce!18023
2018-03-28 09:02:09 +00:00
Douwe Maan 39c911eaaa Fix listing commit branch/tags that contain special characters 2018-03-27 18:20:08 +02:00
Sean McGivern 70af1e2e03 Fix 500 error when trying to resolve non-ASCII conflicts in editor
When we added caching, this meant that calling `can_be_resolved_in_ui?` didn't
always call `lines`, which meant that we didn't get the benefit of the
side-effect from that, where it forced the conflict data itself to UTF-8.

To fix that, make this explicit by separating the `raw_content` (any encoding)
from the `content` (which is either UTF-8, or an exception is raised).
2018-03-23 18:33:14 +00:00
Zeger-Jan van de Weg 77f0906e4c
Change Gitlab::Shell#add_namespace to #create_namespace
Prior to this change, this method was called add_namespace, which broke
the CRUD convention and made it harder to grep for what I was looking
for. Given the change was a find and replace kind of fix, this was
changed without opening an issue and on another feature branch.

If more dynamic calls are made to add_namespace, these could've been
missed which might lead to incorrect bahaviour. However, going through
the commit log it seems thats not the case.
2018-03-14 09:56:22 +01:00
Nick Thomas 91ff0eaa13
Respect the configured git path for imported gitlab-shell operations 2018-03-12 16:03:00 +00:00
Nick Thomas 0649a1f835 Merge branch 'sh-make-prune-optional-in-git-fetch' into 'master'
Make --prune a configurable parameter in fetching a git remote

See merge request gitlab-org/gitlab-ce!17346
2018-03-07 02:02:24 +00:00
Rémy Coutable af84ccbd82 Merge branch '40187-project-branch-dashboard-with-active-stale-branches' into 'master'
Add overview of branches and filtered views for active/stale branches

Closes #40187 et #17293

See merge request gitlab-org/gitlab-ce!15402
2018-03-06 13:14:10 +00:00
Takuya Noguchi 580d895363 Add overview of branches and a filter for active/stale branches 2018-03-06 21:28:14 +09:00
Stan Hu e9fad3e501 Make --prune a configurable parameter in fetching a git remote
By default, --prune is added to the command-line of a `git fetch` operation,
but for repositories with many references this can take a long time to run. We
shouldn't need to run --prune the first time we fetch a new repository.
2018-03-06 00:10:04 -08:00
Douwe Maan 0736197f63 Merge branch 'gitaly-lfs-changes' into 'master'
Incorporate Gitaly's RPCs for Gitlab::Git::LfsChanges

Closes gitaly#1048

See merge request gitlab-org/gitlab-ce!16973
2018-03-05 15:43:26 +00:00
Douwe Maan 899967fbd8 Merge branch 'feature/add-support-for-all-option-in-count-find-commits' into 'master'
Add support for :all option to {count,find}_commits

See merge request gitlab-org/gitlab-ce!17464
2018-03-05 15:41:49 +00:00
Alejandro Rodríguez 0a4ee10eda Fix n+1 issue by not reloading fully loaded blobs 2018-03-05 11:14:43 -03:00
Alejandro Rodríguez a0a7b551ae Incorporate Gitaly's RPCs for Gitlab::Git::LfsChanges 2018-03-02 17:12:08 -03:00
Ahmad Sherif cd770946c4 Add support for :all option to {count,find}_commits 2018-03-02 14:55:20 +01:00
Sean McGivern 40c61acb6a Merge branch 'feature/fetch-commit-signs-from-gitaly-in-batch' into 'master'
Fetch commit signatures from Gitaly in batches

Closes gitaly#1046

See merge request gitlab-org/gitlab-ce!17456
2018-03-02 11:16:20 +00:00
Ahmad Sherif 03f3350f3f Fetch commit signatures from Gitaly in batches
Closes gitaly#1046
2018-03-01 18:31:31 +01:00
Sean McGivern 52e133d176 Merge branch 'zj-licensee-key' into 'master'
Client implementation for Licensee#key

See merge request gitlab-org/gitlab-ce!17449
2018-03-01 17:10:39 +00:00
Douwe Maan de454de9b1 Merge branch '42434-allow-commits-endpoint-to-work-over-all-commits' into 'master'
Resolve "Allow API method /projects/:id/repository/commits  to work over all commits"

Closes #42434

See merge request gitlab-org/gitlab-ce!17182
2018-03-01 15:54:43 +00:00
Zeger-Jan van de Weg 34fbade4ae
Client implementation for Licensee#key
Part of the migration as tracked in: gitlab-org/gitaly#1026
2018-03-01 16:41:08 +01:00
Tiago Botelho cd9daf644e Add specs 2018-03-01 14:38:35 +00:00
Zeger-Jan van de Weg c12b18c545
Encode revision for gitattributes ref
A field didn't call the needed encoding helper, thus some UTF-8 encoding
couldn't be encoded to ASCII. Using the helper method this was fixed.

Tests are now run against Gitaly and Rugged too, to ensure both remain
working correctly.

Fixes gitlab-org/gitaly#1032, gitlab-org/gitlab-ce#43278
2018-03-01 09:18:26 +01:00
Sean McGivern e351f67874 Suppress whitespace warnings in squash error messages
These are obscuring the real error, which is confusing for everyone.
2018-02-26 09:08:17 +00:00
Grzegorz Bizon eb421c88ee Merge branch 'fix-squash-with-renamed-files' into 'master'
Fix squash with renamed files

Closes gitlab-ee#4975

See merge request gitlab-org/gitlab-ce!17216
2018-02-22 11:35:34 +00:00
Douwe Maan e503efa320 Merge branch 'zj-branch-contains-git-message' into 'master'
Allow branchnames to be named the same as the commit it points to

See merge request gitlab-org/gitlab-ce!17231
2018-02-22 11:34:03 +00:00
Zeger-Jan van de Weg e70fe78281
Handle branch and tag names which are commit ids
Adds a test where a branch name is also a valid commit id. Git, the
binary should create an error message which is difficult to parse and
leading to errors later, as seen in: gitlab-org/gitlab-ce#43222

To catch these cases in the future,
gitlab-test@1942eed5cc108b19c7405106e81fa96125d0be22 was created. Which
a branch name matching the commit
2018-02-21 19:08:26 +01:00
Ken ed0a029d53 26039 - update github-linguist to 5.3.3 version
26039 - add merge request id


26039 change due to lingust source file updates
2018-02-21 03:29:04 +10:30
Zeger-Jan van de Weg f42bf66eef
Add unit tests for Gitaly types 2018-02-20 13:57:33 +01:00
Sean McGivern 01f5035bfe Fix squash with renamed files
We need to ignore the names for renamed files when configuring with sparse
checkout.
2018-02-19 15:11:10 +00:00
Stan Hu 8d32dfef9b Fix squash rebase not working when diff contained encoded data
When the applied diff contains UTF-8 or some other encoded data, the diff
returned back from the git process may be in ASCII-8BIT format. Writing this
data to stdin may fail if the data because stdin expects this data to be in
UTF-8. By switching the output to binmode, we ensure that the diff will
always be written as-is.

Closes gitlab-org/gitlab-ee#4960
2018-02-18 21:48:49 -08:00
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