git: Add push().
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
tastytea 2020-07-01 10:24:38 +02:00
parent df60f738f4
commit 90545b0681
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 20 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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
{