Change target branch for pull request (#6488)
* Adds functionality to change target branch of created pull requests Signed-off-by: Mario Lubenka <[email protected]> * Use const instead of var in JavaScript additions Signed-off-by: Mario Lubenka <[email protected]> * Check if branches are equal and if PR already exists before changing target branch Signed-off-by: Mario Lubenka <[email protected]> * Make sure to check all commits Signed-off-by: Mario Lubenka <[email protected]> * Print error messages for user as error flash message Signed-off-by: Mario Lubenka <[email protected]> * Disallow changing target branch of closed or merged pull requests Signed-off-by: Mario Lubenka <[email protected]> * Resolve conflicts after merge of upstream/master Signed-off-by: Mario Lubenka <[email protected]> * Change order of branch select fields Signed-off-by: Mario Lubenka <[email protected]> * Removes duplicate check Signed-off-by: Mario Lubenka <[email protected]> * Use ctx.Tr for translations Signed-off-by: Mario Lubenka <[email protected]> * Recompile JS Signed-off-by: Mario Lubenka <[email protected]> * Use correct translation namespace Signed-off-by: Mario Lubenka <[email protected]> * Remove redundant if condition Signed-off-by: Mario Lubenka <[email protected]> * Moves most change branch logic into pull service Signed-off-by: Mario Lubenka <[email protected]> * Completes comment Signed-off-by: Mario Lubenka <[email protected]> * Add Ref to ChangesPayload for logging changed target branches instead of creating a new struct Signed-off-by: Mario Lubenka <[email protected]> * Revert changes to go.mod Signed-off-by: Mario Lubenka <[email protected]> * Directly use createComment method Signed-off-by: Mario Lubenka <[email protected]> * Return 404 if pull request is not found. Move written check up Signed-off-by: Mario Lubenka <[email protected]> * Remove variable declaration Signed-off-by: Mario Lubenka <[email protected]> * Return client errors on change pull request target errors Signed-off-by: Mario Lubenka <[email protected]> * Return error in commit.HasPreviousCommit Signed-off-by: Mario Lubenka <[email protected]> * Adds blank line Signed-off-by: Mario Lubenka <[email protected]> * Test patch before persisting new target branch Signed-off-by: Mario Lubenka <[email protected]> * Update patch before testing (not working) Signed-off-by: Mario Lubenka <[email protected]> * Removes patch calls when changeing pull request target Signed-off-by: Mario Lubenka <[email protected]> * Removes unneeded check for base name Signed-off-by: Mario Lubenka <[email protected]> * Moves ChangeTargetBranch completely to pull service. Update patch status. Signed-off-by: Mario Lubenka <[email protected]> * Set webhook mode after errors were validated Signed-off-by: Mario Lubenka <[email protected]> * Update PR in one transaction Signed-off-by: Mario Lubenka <[email protected]> * Move logic for check if head is equal with branch to pull model Signed-off-by: Mario Lubenka <[email protected]> * Adds missing comment and simplify return Signed-off-by: Mario Lubenka <[email protected]> * Adjust CreateComment method call Signed-off-by: Mario Lubenka <[email protected]>
This commit is contained in:
committed by
Lunny Xiao
parent
59d6401486
commit
61db834904
@@ -306,6 +306,27 @@ func (c *Commit) CommitsBefore() (*list.List, error) {
|
||||
return c.repo.getCommitsBefore(c.ID)
|
||||
}
|
||||
|
||||
// HasPreviousCommit returns true if a given commitHash is contained in commit's parents
|
||||
func (c *Commit) HasPreviousCommit(commitHash SHA1) (bool, error) {
|
||||
for i := 0; i < c.ParentCount(); i++ {
|
||||
commit, err := c.Parent(i)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if commit.ID == commitHash {
|
||||
return true, nil
|
||||
}
|
||||
commitInParentCommit, err := commit.HasPreviousCommit(commitHash)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if commitInParentCommit {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// CommitsBeforeLimit returns num commits before current revision
|
||||
func (c *Commit) CommitsBeforeLimit(num int) (*list.List, error) {
|
||||
return c.repo.getCommitsBeforeLimit(c.ID, num)
|
||||
|
||||
Reference in New Issue
Block a user