This commit is contained in:
parent
df60f738f4
commit
90545b0681
16
src/git.cpp
16
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Reference in New Issue
Block a user