formatting

This commit is contained in:
2024-12-30 17:36:22 +02:00
parent 4858178f52
commit f0fdf146a8
141 changed files with 1850 additions and 1882 deletions

View File

@@ -5,7 +5,7 @@ import freeflowuniverse.herolib.osal
import time
// Creates a new file in the specified repository path and returns its name.
fn create_new_file(repo_path string, runtime i64)! string {
fn create_new_file(repo_path string, runtime i64) !string {
coded_now := time.now().unix()
file_name := 'hello_world_${coded_now}.py'
println('Creating a new ${file_name} file.')
@@ -29,8 +29,8 @@ mut repo := gs_default.get_repo(name: 'repo3')!
// mut repo := gs_default.get_repo(name: 'repo3' clone: true, url: 'https://github.com/Mahmoud-Emad/repo2.git')!
runtime := time.now().unix()
branch_name := "branch_${runtime}"
tag_name := "tag_${runtime}"
branch_name := 'branch_${runtime}'
tag_name := 'tag_${runtime}'
repo_path := repo.get_path()!
mut file_name := create_new_file(repo_path, runtime)!
@@ -51,36 +51,28 @@ repo.checkout(branch_name: branch_name, pull: false) or {
// Check for changes and stage them if present.
if repo.has_changes()! {
println('Adding the changes...')
repo.add_changes() or {
error('Cannot add the changes due to: ${err}')
}
repo.add_changes() or { error('Cannot add the changes due to: ${err}') }
}
// Check if a commit is needed and commit changes if necessary.
if repo.need_commit()! {
commit_msg := 'feat: Added ${file_name} file.'
println('Committing the changes, Commit message: ${commit_msg}.')
repo.commit(msg: commit_msg) or {
error('Cannot commit the changes due to: ${err}')
}
repo.commit(msg: commit_msg) or { error('Cannot commit the changes due to: ${err}') }
}
// Push changes to the remote repository if necessary.
if repo.need_push()! {
println('Pushing the changes...')
repo.push() or {
error('Cannot push the changes due to: ${err}')
}
repo.push() or { error('Cannot push the changes due to: ${err}') }
}
if repo.need_pull()! {
println('Pulling the changes.')
repo.pull() or {
error('Cannot pull the changes due to: ${err}')
}
repo.pull() or { error('Cannot pull the changes due to: ${err}') }
}
// Checkout to the base branch
// Checkout to the base branch
repo.checkout(checkout_to_base_branch: true, pull: true) or {
error("Couldn't checkout to branch ${branch_name} due to: ${err}")
}
@@ -93,12 +85,8 @@ repo.create_tag(tag_name: tag_name, checkout: false) or {
// Push the created tag.
println('Pushing the tag...')
repo.push(push_tag: true) or {
error('Cannot push the tag due to: ${err}')
}
repo.push(push_tag: true) or { error('Cannot push the tag due to: ${err}') }
// Check if the created tag exists.
println('Check if the created tag exists...')
repo.is_tag_exists(tag_name: tag_name) or {
println("Tag isn't exists.")
}
repo.is_tag_exists(tag_name: tag_name) or { println("Tag isn't exists.") }