bur-manager/sync.v

22 lines
529 B
V

import gitea
import git2
import os
fn sync_repo(c &gitea.Client, repo gitea.Repository) ! {
git_repo_path := os.join_path_single('repos', repo.name)
// Remove old clone if present
if os.exists(git_repo_path) {
os.rmdir_all(git_repo_path)!
}
// Clone the remote repository
git_repo := git2.clone(repo.description, os.join_path_single('repos', '$repo.name-remote'))!
// Add the Gitea repository as a remote
remote := git_repo.create_remote('gitea', repo.clone_url)!
// Fetch the Gitea repository
remote.fetch()!
}