public static Settings GetGitSettings() { var settings = new Settings(); settings.ServerUrl = RegistrySettings.ReadValue("Set Github Url", "GithubUrl"); settings.Organization = RegistrySettings.ReadValue("Set Github organization", "Organization"); settings.Username = RegistrySettings.ReadValue("Set Github username", "Username"); settings.Password = RegistrySettings.ReadValue("Set Github password url", "Password", true); settings.RootDir = RegistrySettings.ReadValue("Set Root directory", "RootDir"); return(settings); }
public static IEnumerable <string> GetRepositoriesWithLocalChanges() { var settings = GetGitSettings(); var dirs = Directory.EnumerateDirectories(settings.RootDir, ".git", SearchOption.AllDirectories); foreach (var dir in dirs.Select(d => new DirectoryInfo(d).Parent.FullName)) { using (var repo = new LibGit2Sharp.Repository(dir, new RepositoryOptions())) { var options = new FetchOptions(); options.CredentialsProvider = new CredentialsHandler((url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = settings.Username, Password = RegistrySettings.DecryptData(settings.Password) }); if (repo.RetrieveStatus().IsDirty) { yield return(dir); } } } }