1 file changed
+22
-3
crates/cli/src/deploy/mod.rs
+22
-3
@@ -53,15 +53,34 @@ pub async fn process_deploy(env: Environment) -> Result<CommandResult> {
53
}
54
};
55
56
- let main_branch = match repo.head() {
57
- Ok(branch) => branch,
56
+ // Get the current branch
57
+ let head = match repo.head() {
58
+ Ok(head) => head,
59
Err(_) => {
60
return Err(anyhow!(fail_message(
60
- "No main branch found. Create with `git checkout -b <branch>` command."
61
+ "No HEAD reference found. Create a commit with `git commit` command."
62
)))
63
}
64
};
65
66
+ // Check if we're on the main branch
67
+ let branch_name = match head.shorthand() {
68
+ Some(name) => name,
69
+ None => {
70
+ return Err(anyhow!(fail_message(
71
+ "Unable to determine current branch name."
72
+ )))
73
+ }
74
+ };
75
+
76
+ if branch_name != "main" && branch_name != "master" {
77
+ return Err(anyhow!(fail_message(
78
+ &format!("Not on main branch. Current branch: '{}'. Switch to main branch with `git checkout main` command.", branch_name)
79
+ )));
80
+ }
81
+
82
+ let main_branch = head;
83
+
84
let mut origin = remote_deployment_setup(&runner, &repo, &config.project.repository).await?;
85
86
let commit_hash = match main_branch.resolve() {