Commit graph

14 commits

Author SHA1 Message Date
GitLab Bot
c019f48555 Add latest changes from gitlab-org/gitlab@master 2020-11-24 21:09:39 +00:00
GitLab Bot
3683fb837c Add latest changes from gitlab-org/gitlab@master 2020-11-17 03:09:06 +00:00
GitLab Bot
e72b53e81e Add latest changes from gitlab-org/gitlab@master 2020-10-02 18:08:56 +00:00
GitLab Bot
08b3b98051 Add latest changes from gitlab-org/gitlab@master 2020-09-01 12:11:01 +00:00
GitLab Bot
99454db49e Add latest changes from gitlab-org/gitlab@master 2020-04-28 06:09:49 +00:00
GitLab Bot
6168721025 Add latest changes from gitlab-org/gitlab@master 2020-02-07 00:09:12 +00:00
GitLab Bot
9a1c545674 Add latest changes from gitlab-org/gitlab@master 2019-10-03 15:07:07 +00:00
GitLab Bot
80f61b4035 Add latest changes from gitlab-org/gitlab@master 2019-09-18 14:02:45 +00:00
GitLab Bot
b7dfe2ae40 Add latest changes from gitlab-org/gitlab@master 2019-09-13 13:26:31 +00:00
Douwe Maan
97c2564ffa
Look up upstream commits once before queuing ProcessCommitWorkers
Instead of checking if a commit already exists in the upstream project
in its ProcessCommitWorker and bailing out if it does, we check the
existence of all commits in bulk in Git::BranchHooksService, so that we
can skip scheduling ProcessCommitWorker jobs for those commits
that already exist upstream entirely.
2019-08-16 13:31:48 -05:00
Patrick Bajao
d96c24d815 Invalidate branches cache on PostReceive
Whenever `PostReceive` is enqueued, `UpdateMergeRequestsWorker`
is enqueued and `MergeRequests::RefreshService` is called, it'll
check if the source branch of each MR asssociated to the push exists
or not via `MergeRequest#source_branch_exists?`. The said method will
call `Repository#branch_exists?` which is cached in `Rails.cache`.

When the cache contains outdated data and the source branch actually
exists, the `MergeRequests#RefreshService` job will close associated
MRs which is not correct.

The fix is to expire the branches cache of the project so we have
updated data during the post receive hook which will help in the
accuracy of the check if we need to close associated MRs or not.
2019-08-09 18:09:06 +08:00
Nick Thomas
b2c73fde79
Look for new branches more carefully
In certain cases, GitLab can miss a PostReceive invocation the first
time a branch is pushed. When this happens, the "branch created" hooks
are not run, which means various features don't work until the branch
is deleted and pushed again.

This MR changes the `Git::BranchPushService` so it checks the cache of
existing branches in addition to the `oldrev` reported for the branch.
If the branch name isn't in the cache, chances are we haven't run the
service yet (it's what refreshes the cache), so we can go ahead and
run it, even through `oldrev` is set.

If the cache has been cleared by some other means in the meantime, then
we'll still fail to run the hooks when we should. Fixing that in the
general case is a larger problem, and we'd need to devote significant
engineering effort to it.

There's a chance that we'll run the relevant hooks *multiple times*
with this change, if there's a race between the branch being created,
and the `PostReceive` worker being run multiple times, but this can
already happen, since Sidekiq is "at-least-once" execution of jobs. So,
this should be safe.
2019-06-18 12:53:53 +01:00
Fabio Papa
352b43e0af Modify the branch hooks spec to expect processing of commit messages
Commit messages are not processed for references to issues when
creating the default branch on push. This was expected
behavior (probably to avoid performance problems when first pushing a
repository with thousands of commits). However, this is not an issue
because we always limit the number of commits to process to 100
regardless of whether we are creating the default branch or not.
2019-06-13 10:46:47 +00:00
Nick Thomas
e46d4bf4da
Extract a Git::{Base,Tag,Branch}HooksService 2019-04-05 18:26:53 +01:00