allow a path for git command

This commit is contained in:
isanae
2020-05-26 13:16:29 -04:00
parent 098e0a95c6
commit 8015e026c1
2 changed files with 60 additions and 18 deletions
+47 -11
View File
@@ -955,7 +955,10 @@ clipp::group git_command::do_group()
"to 'nopushurl' to avoid accidental pushes"),
(clipp::option("-p", "--push-origin").set(push_default_)
% "sets the new 'origin' remote as the default push target")
% "sets the new 'origin' remote as the default push target"),
(clipp::opt_value("path") >> path_)
% "only use this repo"
)
|
@@ -975,7 +978,10 @@ clipp::group git_command::do_group()
% "path to putty key",
(clipp::option("-p", "--push-origin").set(push_default_)
% "sets this new remote as the default push target")
% "sets this new remote as the default push target"),
(clipp::opt_value("path") >> path_)
% "only use this repo"
)
|
@@ -1043,45 +1049,75 @@ std::string git_command::do_doc()
void git_command::do_set_remotes()
{
if (path_.empty())
{
const auto repos = get_repos();
for (auto&& r : repos)
do_set_remotes(r);
}
else
{
do_set_remotes(path_);
}
}
void git_command::do_set_remotes(const fs::path& r)
{
u8cout << "setting up " << path_to_utf8(r.filename()) << "\n";
git::set_credentials(r, username_, email_);
git::set_remote(r, username_, key_, nopush_, push_default_);
}
}
void git_command::do_add_remote()
{
const auto repos = get_repos();
u8cout
<< "adding remote '" << remote_ << "' "
<< "from '" << username_ << "' to repos\n";
for (auto&& r : repos)
if (path_.empty())
{
const auto repos = get_repos();
for (auto&& r : repos)
do_add_remote(r);
}
else
{
do_add_remote(path_);
}
}
void git_command::do_add_remote(const fs::path& r)
{
u8cout << path_to_utf8(r.filename()) << "\n";
git::add_remote(r, remote_, username_, key_, push_default_);
}
}
void git_command::do_ignore_ts()
{
const auto repos = get_repos();
if (tson_)
u8cout << "ignoring .ts files\n";
else
u8cout << "un-ignoring .ts files\n";
for (auto&& r : repos)
if (path_.empty())
{
const auto repos = get_repos();
for (auto&& r : repos)
do_ignore_ts(r);
}
else
{
do_ignore_ts(path_);
}
}
void git_command::do_ignore_ts(const fs::path& r)
{
u8cout << path_to_utf8(r.filename()) << "\n";
git::ignore_ts(r, tson_);
}
}
std::vector<fs::path> git_command::get_repos() const
+6
View File
@@ -211,13 +211,19 @@ private:
std::string email_;
std::string key_;
std::string remote_;
std::string path_;
bool tson_ = false;
bool nopush_ = false;
bool push_default_ = false;
void do_set_remotes();
void do_set_remotes(const fs::path& r);
void do_add_remote();
void do_add_remote(const fs::path& r);
void do_ignore_ts();
void do_ignore_ts(const fs::path& r);
std::vector<fs::path> get_repos() const;
};