diff --git a/src/git.cpp b/src/git.cpp index 59be8e7..f5936d7 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -191,4 +191,20 @@ void commit(const entry_type &entry) git_tree_free(tree); } +void push() +{ + git_push_options options; + git_remote *remote{nullptr}; + const string branch_name{"web-" + std::to_string(get_last_id() + 1)}; + string refspec_str{("refs/heads/" + branch_name)}; + char *refspec = &refspec_str[0]; + const git_strarray refspecs = {&refspec, 1}; + + check(git_remote_lookup(&remote, _repo, "origin")); + check(git_push_options_init(&options, GIT_PUSH_OPTIONS_VERSION)); + options.callbacks.credentials = cred_aquire; + + check(git_remote_push(remote, &refspecs, &options)); +} + } // namespace FediBlock::git diff --git a/src/git.hpp b/src/git.hpp index 6b138bc..b2066e8 100644 --- a/src/git.hpp +++ b/src/git.hpp @@ -49,6 +49,9 @@ void create_branch(); // Make a new commit. void commit(const entry_type &entry); +// Push the new commit. +void push(); + } // namespace FediBlock::git #endif // FEDIBLOCK_BACKEND_GIT_HPP diff --git a/src/main.cpp b/src/main.cpp index e765d14..84a0cf1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,6 +70,7 @@ int main() cout << "Next branch ID: " << git::get_last_id() + 1 << "\r\n"; git::create_branch(); git::commit(entry); + git::push(); try {