• Georges Racinet's avatar
    Branch acces checks: direct identification of legit merges · 948dac54b949
    Georges Racinet authored
    Closes #368
    
    To let merges done from the Rails application be checked
    against the distinct set of merge rules rather that push
    rules, GitLab looks for MRs matching the pre-receive changes by
    comparing with the merge commit sha that's always available
    (and set by the Repository Model) before the actual branch move.
    
    Because the Mercurial change can be atomic, we have no other
    option than passing a special parameter down from
    `Repository#merge` through the Mercurial backend, with the
    `HEPTAPOD_ACCEPT_MERGE_ID` environment variable.
    In turn the Mercurial process will add it to its pre-receive
    hook payload, and the target branch can be compared to switch
    from (direct) push to (Rails) merge mode.
    
    In the case of merges intended from the very beginning to be
    fast forwards, the commit sha is already known in advance,
    but we're using the same mechanism for consistency in the
    check.
    
    Finally, there was a good dose of wrestling with those RSpec
    examples that care about merging to a protected branch, because
    of the on-demand nature of instantiation.
    
    --HG--
    branch : heptapod-stable
    948dac54b949