• Will Chandler's avatar
    Expand branch creation error message · 727a0716
    Will Chandler authored
    Currently when `repository#add_branch` returns `false` in
    `Branches::CreateService` we return error message that the source
    reference was invalid. This is the most likely cause of this error, but
    not the only one.
    
    Another cause is creating a branch with a subcomponent that matches the
    full name of an existing branch, e.g. `feature/widget` and `feature`. In
    this scenario it is the new branch name that is the problem, not the
    source ref, but our error message gives no clues to this.
    
    This is a particular problem for pull mirroring, where the SHA1 of the
    source branch is used rather than a human-readable name. This requires
    the user to copy down the SHA and go to the source repo to attempt to
    understand which branch is causing the failure.
    
    Ideally we would have separate errors for invalid source refs and
    invalid branch names, but `repository#add_branch` hides the information
    we need to distinguish between them.
    
    This commit expands the error message to mention which branch we failed
    to create, making it easier for users to find out they were creating
    invalid branch names.
    727a0716
create_spec.rb 1.39 KB