diff --git a/src/server/gitforge/forgejo/branch/validate_positions.rs b/src/server/gitforge/forgejo/branch/validate_positions.rs index 031063f..dc519d2 100644 --- a/src/server/gitforge/forgejo/branch/validate_positions.rs +++ b/src/server/gitforge/forgejo/branch/validate_positions.rs @@ -51,6 +51,17 @@ pub async fn validate_positions( ); return Err(Error::BranchHasNoCommits(repo_config.branches().main())); }; + // Dev must be on main branch, or user must rebase it + let dev_has_main = commit_histories.dev.iter().any(|commit| commit == &main); + if !dev_has_main { + warn!( + "Dev branch '{}' is not based on main branch '{}' - user should rebase onto main branch '{}'", + repo_config.branches().dev(), + repo_config.branches().main(), + repo_config.branches().main(), + ); + return Err(Error::DevBranchNotBasedOn(repo_config.branches().main())); + } // verify that next is an ancestor of dev, and force update to it main if it isn't let Some(next) = commit_histories.next.first().cloned() else { warn!( @@ -119,16 +130,7 @@ pub async fn validate_positions( ); return Err(Error::DevBranchNotBasedOn(repo_config.branches().next())); // dev is not based on next } - let dev_has_main = commit_histories.dev.iter().any(|commit| commit == &main); - if !dev_has_main { - warn!( - "Dev branch '{}' is not based on main branch '{}' - user should rebase onto main branch '{}'", - repo_config.branches().dev(), - repo_config.branches().main(), - repo_config.branches().main(), - ); - return Err(Error::DevBranchNotBasedOn(repo_config.branches().main())); - } + let Some(dev) = commit_histories.dev.first().cloned() else { warn!( "No commits on dev branch '{}'",