Add some more mock git commands

This commit is contained in:
Alex 2024-07-26 08:48:17 +02:00
parent bc14726c1b
commit 87a6b5b132
Signed by: l-x
SSH key fingerprint: SHA256:MK3uQVPHEV0Oo2ry/dAqvVK3pAwegKAwSlyfgLd/yQM
2 changed files with 46 additions and 8 deletions

View file

@ -1,4 +1,5 @@
import * from "../config.ab" import * from "../config.ab"
import * from "../git/branch.ab"
fun branch(feature: Text): Text { fun branch(feature: Text): Text {
let prefix = get_feature_prefix() let prefix = get_feature_prefix()
@ -8,20 +9,20 @@ fun branch(feature: Text): Text {
fun feature_start(feature: Text, description: Text): Null { fun feature_start(feature: Text, description: Text): Null {
let branch = branch(feature) let branch = branch(feature)
let base = get_dev_branch()
echo "git switch -c {branch} {base}" unsafe branch_create(branch, get_dev_branch())
echo "git config --no-add branch.\"{branch}\".description \"{description}\"" unsafe branch_set_description(branch, description)
} }
fun feature_checkout(feature: Text): Null { fun feature_checkout(feature: Text): Null {
let branch = branch(feature) unsafe branch_checkout(branch(feature))
echo "git checkout \"{branch}\""
} }
fun feature_publish(feature: Text): Null { fun feature_publish(feature: Text): Null {
echo "Publish feature {feature}" unsafe branch_push(
branch(feature),
get_push_remote()
)
} }
fun feature_finish(feature: Text): Null { fun feature_finish(feature: Text): Null {
@ -29,7 +30,14 @@ fun feature_finish(feature: Text): Null {
} }
fun feature_delete(feature: Text): Null { fun feature_delete(feature: Text): Null {
echo "Delete feature {feature}" let dev_branch = get_dev_branch()
let branch = branch(feature)
if branch_get_current() == dev_branch {
branch_checkout(dev_branch)
}
branch_delete(branch)
} }
fun feature_rebase(feature: Text): Null { fun feature_rebase(feature: Text): Null {

30
git/branch.ab Normal file
View file

@ -0,0 +1,30 @@
import * from "../config.ab"
pub fun branch_get_current(): Text {
return unsafe $git branch --show-current$
}
pub fun branch_create(branch: Text, start_point: Text): Null {
echo "git switch -c \"{branch}\" \"{start_point}\""
// $git switch -c "{branch}" "{start_point}"$?
}
pub fun branch_checkout(branch: Text): Null {
echo "git checkout \"{branch}\""
// $git checkout "{branch}$?
}
pub fun branch_delete(branch: Text): Null {
echo "git branch -d \"{branch}\""
// $git branch -d "{branch}"$?
}
pub fun branch_set_description(branch: Text, description: Text): Null {
echo "git config --no-add branch.\"{branch}\".description \"{description}\""4
// $git config --no-add branch."{branch}".description "{description}"$?
}
pub fun branch_push(branch: Text, remote: Text): Null {
echo "git push \"{remote}\" \"{branch}\""
// $git push "{remote}" "{branch}"$?
}