Skip to content

Commit 954587d

Browse files
committed
address review comments
1 parent 2ba0ac9 commit 954587d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/subcommand/commit_subcommand.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ commit_subcommand::commit_subcommand(const libgit2_object&, CLI::App& app)
1010
{
1111
auto *sub = app.add_subcommand("commit", "Record changes to the repository");
1212

13+
// TODO: merge the following option and flag into: sub->add_option("-m,--message", m_commit_message, "Commit message")
14+
// when we have a solution to ask for a message when not using the -m flag.
1315
sub->add_option("commit_message", m_commit_message, "Commit message");
1416

1517
sub->add_flag("-m,--message", m_commit_message_flag, "");
@@ -23,12 +25,16 @@ void commit_subcommand::run()
2325
auto directory = get_current_git_path();
2426
auto bare = false;
2527
auto repo = repository_wrapper::init(directory, bare);
26-
auto author_committer_signatures = signature_wrapper::get_default_signature_from_env(repo);
28+
auto author_committer_signatures = signature_wrapper::get_default_signature_from_env(repo);
2729

2830
if (!m_commit_message_flag)
2931
{
3032
throw std::runtime_error("Please provide a message using the -m flag.");
3133
}
34+
if (m_commit_message.empty())
35+
{
36+
throw std::runtime_error("Please provide a commit message.");
37+
}
3238

3339
repo.create_commit(author_committer_signatures, m_commit_message);
3440
}

0 commit comments

Comments
 (0)