- A
- B
- C
- D
- F
- H
- L
- M
- O
- P
- R
- T
- U
- V
BROKEN_DIFF | = | "--broken-diff" |
UNCHECKED | = | 1 |
CAN_BE_MERGED | = | 2 |
CANNOT_BE_MERGED | = | 3 |
[RW] | should_remove_source_branch |
Source: show
# File app/models/merge_request.rb, line 47 def self.find_all_by_branch(branch_name) where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) end
Source: show
# File app/models/merge_request.rb, line 51 def self.find_all_by_milestone(milestone) where("milestone_id = :milestone_id", milestone_id: milestone) end
Source: show
# File app/models/merge_request.rb, line 195 def automerge!(current_user) if Gitlab::Satellite::MergeAction.new(current_user, self).merge! && self.unmerged_commits.empty? self.merge!(current_user.id) true end rescue self.mark_as_unmergable false end
Source: show
# File app/models/merge_request.rb, line 112 def broken_diffs? diffs == [BROKEN_DIFF] end
Source: show
# File app/models/merge_request.rb, line 84 def can_be_merged? state == CAN_BE_MERGED end
Source: show
# File app/models/merge_request.rb, line 88 def check_if_can_be_merged self.state = if Gitlab::Satellite::MergeAction.new(self.author, self).can_be_merged? CAN_BE_MERGED else CANNOT_BE_MERGED end self.save end
Source: show
# File app/models/merge_request.rb, line 140 def closed_event self.project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::Closed).last end
Source: show
# File app/models/merge_request.rb, line 144 def commits st_commits || [] end
Source: show
# File app/models/merge_request.rb, line 55 def human_state states = { CAN_BE_MERGED => "can_be_merged", CANNOT_BE_MERGED => "cannot_be_merged", UNCHECKED => "unchecked" } states[self.state] end
Source: show
# File app/models/merge_request.rb, line 128 def last_commit commits.first end
Source: show
# File app/models/merge_request.rb, line 224 def last_commit_short_sha @last_commit_short_sha ||= last_commit.sha[0..10] end
Source: show
# File app/models/merge_request.rb, line 157 def mark_as_merged! self.merged = true self.closed = true save end
Source: show
# File app/models/merge_request.rb, line 79 def mark_as_unchecked self.state = UNCHECKED self.save end
Source: show
# File app/models/merge_request.rb, line 163 def mark_as_unmergable self.state = CANNOT_BE_MERGED self.save end
Source: show
# File app/models/merge_request.rb, line 184 def merge!(user_id) self.mark_as_merged! Event.create( project: self.project, action: Event::Merged, target_id: self.id, target_type: "MergeRequest", author_id: user_id ) end
Source: show
# File app/models/merge_request.rb, line 136 def merge_event self.project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::Merged).last end
Source: show
# File app/models/merge_request.rb, line 132 def merged? merged && merge_event end
Source: show
# File app/models/merge_request.rb, line 205 def mr_and_commit_notes commit_ids = commits.map(&:id) Note.where("(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))", mr_id: id, commit_ids: commit_ids) end
Source: show
# File app/models/merge_request.rb, line 148 def probably_merged? unmerged_commits.empty? && commits.any? && open? end
Source: show
# File app/models/merge_request.rb, line 70 def reload_code self.reloaded_commits self.reloaded_diffs end
Source: show
# File app/models/merge_request.rb, line 168 def reloaded_commits if open? && unmerged_commits.any? self.st_commits = unmerged_commits save end commits end
Source: show
# File app/models/merge_request.rb, line 101 def reloaded_diffs if open? && unmerged_diffs.any? self.st_diffs = unmerged_diffs self.save end rescue Grit::Git::GitTimeout self.st_diffs = [BROKEN_DIFF] self.save end
Returns the raw diff for this merge request
see “git diff”
Source: show
# File app/models/merge_request.rb, line 213 def to_diff project.repo.git.native(:diff, {timeout: 30, raise: true}, "#{target_branch}...#{source_branch}") end
Returns the commit as a series of email patches.
see “git format-patch”
Source: show
# File app/models/merge_request.rb, line 220 def to_patch project.repo.git.format_patch({timeout: 30, raise: true, stdout: true}, "#{target_branch}..#{source_branch}") end
Source: show
# File app/models/merge_request.rb, line 75 def unchecked? state == UNCHECKED end
Source: show
# File app/models/merge_request.rb, line 176 def unmerged_commits self.project.repo. commits_between(self.target_branch, self.source_branch). map {|c| Commit.new(c)}. sort_by(&:created_at). reverse end
Source: show
# File app/models/merge_request.rb, line 120 def unmerged_diffs # Only show what is new in the source branch compared to the target branch, not the other way around. # The linex below with merge_base is equivalent to diff with three dots (git diff branch1...branch2) # From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B" common_commit = project.repo.git.native(:merge_base, {}, [target_branch, source_branch]).strip diffs = project.repo.diff(common_commit, source_branch) end