Open ming4883 opened 8 years ago
Hi! Is there any motion on this issue?
Not yet! We'd welcome a pull request if this is something that you're interested in! 😀
is Repository.Submodules
bound to a specific branch (e.g. to the current checked out branch)? if so, how can I get the submodules of other branches? do we need to have git_submodule_branch
supported? how would that work?
currently, I'm traversing the tree looking for GitLink
objects and resorting to manual parsing the .gitmodules
files. I think this is something that should be provided out-of-the-box by libgit2sharp. if you point me to the right direction, I'm willing to contribute a PR.
Since .gitmodules is using the standard git config file format, I parse this file using the built-in Configuration.BuildFrom().
// using GitLib = LibGit2Sharp;
var _cfg = GitLib.Configuration.BuildFrom(_pathToGitModules);
foreach (var _c in _cfg)
{
if (_c.Level != GitLib.ConfigurationLevel.Local) // ignore any global and system config
continue;
string[] _keys = _c.Key.Split(new char[] { '.' });
if (string.Compare(_keys[0], "submodule") != 0 || _keys.Length < 3)
continue;
// where _keys[1] is the submodule name
// _keys[2] is the key to the submodule value
// _c.Value is the value
Dictionary<string, string> _submod = GetSubModuleByName(_keys[1]);
_submod[_keys[2]] = _c.Value;
}
Hope this helps.
Please support the git_submodule_branch() API, so that the branch attributes inside ".gitmodules" can be retrieved.
Information about the API: https://libgit2.github.com/libgit2/#HEAD/group/submodule/git_submodule_branch
Thanks