mirror of
https://github.com/ModOrganizer2/mob.git
synced 2026-07-27 14:07:05 -07:00
Merge pull request #107 from ModOrganizer2/dev/fallback-mo-branch
Allow for a fallback branch when building.
This commit is contained in:
@@ -22,12 +22,13 @@ super = cmake_common modorganizer* githubpp
|
||||
plugins = check_fnis bsapacker bsa_extractor diagnose_basic installer_* plugin_python preview_base preview_bsa tool_* game_*
|
||||
|
||||
[task]
|
||||
enabled = true
|
||||
mo_org = ModOrganizer2
|
||||
mo_branch = master
|
||||
no_pull = false
|
||||
ignore_ts = false
|
||||
revert_ts = false
|
||||
enabled = true
|
||||
mo_org = ModOrganizer2
|
||||
mo_branch = master
|
||||
mo_fallback =
|
||||
no_pull = false
|
||||
ignore_ts = false
|
||||
revert_ts = false
|
||||
|
||||
git_url_prefix = https://github.com/
|
||||
git_shallow = true
|
||||
|
||||
@@ -129,6 +129,8 @@ Unless otherwise stated, applies to any task that is a git repo.
|
||||
| --- | --- | --- |
|
||||
| `mo_org` | string | The organisation name when pulling from Github. Only applies to ModOrganizer projects, plus NCC and usvfs. |
|
||||
| `mo_branch` | string | The branch name when pulling from Github. Only applies to ModOrganizer projects, plus NCC and usvfs. |
|
||||
| `mo_master` | string | The fallback branch name when pulling from Github. Only applies to ModOrganizer projects, plus NCC and usvfs.
|
||||
This branch is used when `mo_branch` does not exists. If this value is empty, the fallback mechanism is disabled (default behavior). |
|
||||
| `no_pull` | bool | If a repo is already cloned, a `git pull` will be done on it every time `mob build` is run. Set to `false` to never pull and build with whatever is in there. |
|
||||
| `ignore_ts` | bool | Marks all the `.ts` files in a repo with `--assume-unchanged`. Note that `mob git ignore-ts off` can be used to revert it. |
|
||||
| `git_url_prefix` | string | When cloning a repo, the URL will be `$(git_url_prefix)mo_org/repo.git`. |
|
||||
|
||||
+15
-14
@@ -131,20 +131,21 @@ public:
|
||||
return get_bool(key);
|
||||
}
|
||||
|
||||
std::string mo_org() const { return get("mo_org"); }
|
||||
std::string mo_branch() const { return get("mo_branch"); }
|
||||
bool no_pull() const { return get<bool>("no_pull"); }
|
||||
bool revert_ts() const { return get<bool>("revert_ts"); }
|
||||
bool ignore_ts()const { return get<bool>("ignore_ts"); }
|
||||
std::string git_url_prefix() const { return get("git_url_prefix"); }
|
||||
bool git_shallow() const { return get<bool>("git_shallow"); }
|
||||
std::string git_user() const { return get("git_username"); }
|
||||
std::string git_email() const { return get("git_email"); }
|
||||
bool set_origin_remote() const { return get<bool>("set_origin_remote"); }
|
||||
std::string remote_org() const { return get("remote_org"); }
|
||||
std::string remote_key() const { return get("remote_key"); }
|
||||
bool remote_no_push_upstream() const { return get<bool>("remote_no_push_upstream"); }
|
||||
bool remote_push_default_origin() const { return get<bool>("remote_push_default_origin"); }
|
||||
std::string mo_org() const { return get("mo_org"); }
|
||||
std::string mo_branch() const { return get("mo_branch"); }
|
||||
std::string mo_fallback_branch() const { return get("mo_fallback"); }
|
||||
bool no_pull() const { return get<bool>("no_pull"); }
|
||||
bool revert_ts() const { return get<bool>("revert_ts"); }
|
||||
bool ignore_ts()const { return get<bool>("ignore_ts"); }
|
||||
std::string git_url_prefix() const { return get("git_url_prefix"); }
|
||||
bool git_shallow() const { return get<bool>("git_shallow"); }
|
||||
std::string git_user() const { return get("git_username"); }
|
||||
std::string git_email() const { return get("git_email"); }
|
||||
bool set_origin_remote() const { return get<bool>("set_origin_remote"); }
|
||||
std::string remote_org() const { return get("remote_org"); }
|
||||
std::string remote_key() const { return get("remote_key"); }
|
||||
bool remote_no_push_upstream() const { return get<bool>("remote_no_push_upstream"); }
|
||||
bool remote_push_default_origin() const { return get<bool>("remote_push_default_origin"); }
|
||||
|
||||
private:
|
||||
std::vector<std::string> names_;
|
||||
|
||||
@@ -153,10 +153,19 @@ void modorganizer::do_fetch()
|
||||
// make sure the super directory is initialized, only done once
|
||||
initialize_super(cx(), super_path());
|
||||
|
||||
// find the best suitable branch
|
||||
const auto fallback = task_conf().mo_fallback_branch();
|
||||
auto branch = task_conf().mo_branch();
|
||||
if (!fallback.empty() && !git_wrap::remote_branch_exists(git_url(), branch)) {
|
||||
cx().warning(context::generic,
|
||||
"{} has no remote {} branch, switching to {}", repo_, branch, fallback);
|
||||
branch = fallback;
|
||||
}
|
||||
|
||||
// clone/pull
|
||||
run_tool(make_git()
|
||||
.url(git_url())
|
||||
.branch(task_conf().mo_branch())
|
||||
.branch(branch)
|
||||
.root(source_path()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user