Skip to content

Commit d6c35c3

Browse files
committed
edit option
1 parent 954587d commit d6c35c3

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/subcommand/commit_subcommand.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ 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.
15-
sub->add_option("commit_message", m_commit_message, "Commit message");
16-
17-
sub->add_flag("-m,--message", m_commit_message_flag, "");
13+
sub->add_option("-m,--message", m_commit_message, "Commit message");
1814

1915
sub->callback([this]() { this->run(); });
2016
};
@@ -27,13 +23,14 @@ void commit_subcommand::run()
2723
auto repo = repository_wrapper::init(directory, bare);
2824
auto author_committer_signatures = signature_wrapper::get_default_signature_from_env(repo);
2925

30-
if (!m_commit_message_flag)
31-
{
32-
throw std::runtime_error("Please provide a message using the -m flag.");
33-
}
3426
if (m_commit_message.empty())
3527
{
36-
throw std::runtime_error("Please provide a commit message.");
28+
std::cout << "Please enter a commit message: " << std::endl;
29+
std::getline(std::cin, m_commit_message);
30+
if (m_commit_message.empty())
31+
{
32+
throw std::runtime_error("Aborting, no commit message specified.");
33+
}
3734
}
3835

3936
repo.create_commit(author_committer_signatures, m_commit_message);

src/subcommand/commit_subcommand.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ class commit_subcommand
1212
void run();
1313

1414
private:
15-
bool m_commit_message_flag = true; // TODO: change to false when a message can be provided if the "-m" flag is not provided
1615
std::string m_commit_message;
1716
};

0 commit comments

Comments
 (0)