git-workflow/cmd/feature.ab

67 lines
1.5 KiB
Text
Raw Permalink Normal View History

2024-07-25 18:36:55 +02:00
import * from "../config.ab"
2024-07-26 08:48:17 +02:00
import * from "../git/branch.ab"
2024-07-25 18:36:55 +02:00
fun branch(feature: Text): Text {
let prefix = get_feature_prefix()
return "{prefix}{feature}"
}
2024-07-25 17:59:52 +02:00
fun feature_start(feature: Text, description: Text): Null {
2024-07-25 18:36:55 +02:00
let branch = branch(feature)
2024-07-26 08:48:17 +02:00
unsafe branch_create(branch, get_dev_branch())
unsafe branch_set_description(branch, description)
2024-07-25 17:59:52 +02:00
}
fun feature_checkout(feature: Text): Null {
2024-07-26 08:48:17 +02:00
unsafe branch_checkout(branch(feature))
2024-07-25 17:59:52 +02:00
}
fun feature_publish(feature: Text): Null {
2024-07-26 08:48:17 +02:00
unsafe branch_push(
branch(feature),
get_push_remote()
)
2024-07-25 17:59:52 +02:00
}
fun feature_finish(feature: Text): Null {
echo "Finish feature {feature}"
}
fun feature_delete(feature: Text): Null {
2024-07-26 08:48:17 +02:00
let dev_branch = get_dev_branch()
let branch = branch(feature)
if branch_get_current() == dev_branch {
branch_checkout(dev_branch)
}
branch_delete(branch)
2024-07-25 17:59:52 +02:00
}
fun feature_rebase(feature: Text): Null {
echo "Rebase feature {feature}"
}
fun help(args: [Text]): Null {
echo "Feature help"
}
pub fun feature_cmd(args: [Text]): Null {
let cmd = args[1]
let feature = args[2]
if {
cmd == "": help(args)
cmd == "start": feature_start(feature, args[3])
cmd == "checkout": feature_checkout(feature)
cmd == "publish": feature_publish(feature)
cmd == "finish": feature_finish(feature)
cmd == "rebase": feature_rebase(feature)
cmd == "delete": feature_delete(feature)
else: echo "Unknown command feature '{cmd}'"
}
}