public static VersionVariables GetVersion(string directory, Authentication authentication, bool noFetch, IFileSystem fileSystem) { var gitDir = GitDirFinder.TreeWalkForDotGitDir(directory); using (var repo = RepositoryLoader.GetRepo(gitDir)) { var ticks = DirectoryDateFinder.GetLastDirectoryWrite(directory); var key = string.Format("{0}:{1}:{2}", repo.Head.CanonicalName, repo.Head.Tip.Sha, ticks); CachedVersion result; if (versionCacheVersions.TryGetValue(key, out result)) { if (result.Timestamp != ticks) { Logger.WriteInfo("Change detected. flushing cache."); result.VersionVariables = ExecuteCore.ExecuteGitVersion(fileSystem, null, null, authentication, null, noFetch, directory, null); } return(result.VersionVariables); } Logger.WriteInfo("Version not in cache. Calculating version."); return((versionCacheVersions[key] = new CachedVersion { VersionVariables = ExecuteCore.ExecuteGitVersion(fileSystem, null, null, authentication, null, noFetch, directory, null), Timestamp = ticks }).VersionVariables); } }
public static CachedVersion GetVersion(string gitDirectory) { using (var repo = RepositoryLoader.GetRepo(gitDirectory)) { var ticks = DirectoryDateFinder.GetLastDirectoryWrite(gitDirectory); var key = string.Format("{0}:{1}:{2}", repo.Head.CanonicalName, repo.Head.Tip.Sha, ticks); CachedVersion cachedVersion; if (versionCacheVersions.TryGetValue(key, out cachedVersion)) { if (cachedVersion.Timestamp != ticks) { Logger.WriteInfo("Change detected. flushing cache."); cachedVersion.SemanticVersion = GitVersionFinder.GetSemanticVersion(repo); cachedVersion.MasterReleaseDate = LastVersionOnMasterFinder.Execute(repo, repo.Head.Tip); } return(cachedVersion); } Logger.WriteInfo("Version not in cache. Calculating version."); //TODO: cope with githubflow //if (GitVersionFinder.ShouldGitHubFlowVersioningSchemeApply(repo)) //{ // return rd; //} return(versionCacheVersions[key] = new CachedVersion { SemanticVersion = GitVersionFinder.GetSemanticVersion(repo), MasterReleaseDate = LastVersionOnMasterFinder.Execute(repo, repo.Head.Tip), Timestamp = ticks }); } }
public void test_zipcode_by_state() { var _zipCodeRepository = new ZipCodeRepository(); RepositoryLoader.Init <ZipCodeRepository>(_zipCodeRepository); var states = _zipCodeRepository.GetByState("India"); }
public void test_zipcode_get() { var _zipCodeRepository = new ZipCodeRepository(); RepositoryLoader.Init <ZipCodeRepository>(_zipCodeRepository); var output = _zipCodeRepository.GetByZip("00501"); }
public static CachedVersion GetVersion(string gitDirectory, Config configuration) { using (var repo = RepositoryLoader.GetRepo(gitDirectory)) { var versionFinder = new GitVersionFinder(); var context = new GitVersionContext(repo, configuration); var ticks = DirectoryDateFinder.GetLastDirectoryWrite(gitDirectory); var key = string.Format("{0}:{1}:{2}", repo.Head.CanonicalName, repo.Head.Tip.Sha, ticks); CachedVersion cachedVersion; if (versionCacheVersions.TryGetValue(key, out cachedVersion)) { if (cachedVersion.Timestamp != ticks) { Logger.WriteInfo("Change detected. flushing cache."); cachedVersion.SemanticVersion = versionFinder.FindVersion(context); cachedVersion.MasterReleaseDate = LastMinorVersionFinder.Execute(repo, new Config(), repo.Head.Tip); } return(cachedVersion); } Logger.WriteInfo("Version not in cache. Calculating version."); return(versionCacheVersions[key] = new CachedVersion { SemanticVersion = versionFinder.FindVersion(context), MasterReleaseDate = LastMinorVersionFinder.Execute(repo, new Config(), repo.Head.Tip), Timestamp = ticks }); } }
public static Tuple <CachedVersion, GitVersionContext> GetVersion(string gitDirectory, Config configuration) { using (var repo = RepositoryLoader.GetRepo(gitDirectory)) { var versionFinder = new GitVersionFinder(); var context = new GitVersionContext(repo, configuration); var ticks = DirectoryDateFinder.GetLastDirectoryWrite(gitDirectory); var key = string.Format("{0}:{1}:{2}", repo.Head.CanonicalName, repo.Head.Tip.Sha, ticks); Tuple <CachedVersion, GitVersionContext> result; if (versionCacheVersions.TryGetValue(key, out result)) { if (result.Item1.Timestamp != ticks) { Logger.WriteInfo("Change detected. flushing cache."); result.Item1.SemanticVersion = versionFinder.FindVersion(context); } return(result); } Logger.WriteInfo("Version not in cache. Calculating version."); return(versionCacheVersions[key] = Tuple.Create(new CachedVersion { SemanticVersion = versionFinder.FindVersion(context), Timestamp = ticks }, context)); } }
public void ItCanLoadLocalRepositoryWithTemplates() { var logger = NullLogger <RepositoryLoader> .Instance; var fileSystem = new MockFileSystem(); fileSystem.AddDirectory("/opt/stamp/repos/.local/templates/TestTemplate@1"); var stampConfig = Mock.Of <IStampConfig>(config => config.GetLocalRepositoryPath() == PurePath.Create("/opt/stamp/repos/.local") ); var expectedTemplateName = "TestTemplate"; var expectedTemplateVersion = SemVersion.Parse("1.0.0"); var templateLoader = Mock.Of <ITemplateLoader>(loader => loader.LoadFromTemplateDirectory(It.IsAny <IPurePath>()) == Mock.Of <ITemplate>(template => template.Name == expectedTemplateName && template.Version == expectedTemplateVersion ) ); var repositoryLoader = new RepositoryLoader(fileSystem, templateLoader, stampConfig, logger); var repository = repositoryLoader.LoadLocalRepository(); repository.Should().NotBeNull(); repository.Name.Should().Be(".local"); repository.Description.Should().Be("Local repository"); repository.Templates.Count.Should().Be(1); repository.Templates[0].Name.Should().Be(expectedTemplateName); repository.Templates[0].Version.Should().Be(expectedTemplateVersion); }
public void test_zipcode_insert() { var _zipCodeRepository = new ZipCodeRepository(); RepositoryLoader.Init <ZipCodeRepository>(_zipCodeRepository); _zipCodeRepository.Insert(new ZipCode { City = "Delhi", StateId = 187, Zip = "9101", County = "Delhi", AreaCode = 01, Fips = 18095, TimeZone = "IST", ObservesDST = false, Latitude = 40.2561, Longitude = -85.6514 }); }
public static void ActualizeRepositories(IPlatformInfo platform, ICollection <RepositoryModel> repositories, string filePath) { var savedVersions = repositories.Select(r => r.Version).ToList(); foreach (var ver in RepositoryLoader.GetVersions(platform).Where(v => !savedVersions.Contains(v))) { foreach (var directoryPath in Directory.GetDirectories(filePath)) { var dirName = System.IO.Path.GetFileName(directoryPath); var localPath = string.Format(platform.LocalPath, ver); if (dirName != localPath) { continue; } if (!File.Exists(directoryPath + "\\VisualTestsConfig.xml")) { continue; } var repository = new RepositoryModel(Repository.CreateRegular(platform.Name, ver, directoryPath + "\\"), platform); repositories.Add(repository); InitializeBinIfNeed(repository.Path, repository.Version); } } }
public static Context ParseArguments(List <string> commandLineArguments, IProviderManager providerManager) { var context = new Context(providerManager); if (commandLineArguments.Count == 0) { context.IsHelp = true; return(context); } var firstArgument = commandLineArguments.First(); if (IsHelp(firstArgument)) { context.IsHelp = true; return(context); } if (commandLineArguments.Count < 3 && commandLineArguments.Count != 1) { throw Log.ErrorAndCreateException <GitLinkException>("Invalid number of arguments"); } context.SolutionDirectory = firstArgument; var namedArguments = commandLineArguments.Skip(1).ToList(); for (var index = 0; index < namedArguments.Count; index++) { var name = namedArguments[index]; // First check everything without values if (IsSwitch("debug", name)) { context.IsDebug = true; continue; } if (IsSwitch("errorsaswarnings", name)) { context.ErrorsAsWarnings = true; continue; } if (IsSwitch("skipverify", name)) { context.SkipVerify = true; continue; } // After this point, all arguments should have a value index++; var valueInfo = GetValue(namedArguments, index); var value = valueInfo.Key; index = index + (valueInfo.Value - 1); if (IsSwitch("l", name)) { context.LogFile = value; continue; } if (IsSwitch("c", name)) { context.ConfigurationName = value; continue; } if (IsSwitch("p", name)) { context.PlatformName = value; continue; } if (IsSwitch("u", name)) { context.TargetUrl = value; continue; } if (IsSwitch("b", name)) { context.TargetBranch = value; continue; } if (IsSwitch("s", name)) { context.ShaHash = value; continue; } if (IsSwitch("f", name)) { context.SolutionFile = value; continue; } if (IsSwitch("d", name)) { context.PdbFilesDirectory = value; continue; } if (IsSwitch("ignore", name)) { context.IgnoredProjects.AddRange(value.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim())); continue; } throw Log.ErrorAndCreateException <GitLinkException>("Could not parse command line parameter '{0}'.", name); } if (string.IsNullOrEmpty(context.TargetUrl)) { Log.Info("No target url was specified, trying to determine the target url automatically"); var gitDir = GitDirFinder.TreeWalkForGitDir(context.SolutionDirectory); if (gitDir != null) { using (var repo = RepositoryLoader.GetRepo(gitDir)) { var currentBranch = repo.Head; if (string.IsNullOrEmpty(context.ShaHash)) { context.ShaHash = currentBranch.Tip.Sha; } if (currentBranch.Remote == null || currentBranch.IsDetachedHead()) { currentBranch = repo.GetBranchesContainingCommit(context.ShaHash).FirstOrDefault(b => b.Remote != null); } if (currentBranch != null && currentBranch.Remote != null) { var url = currentBranch.Remote.Url; if (url.StartsWith("https://")) { context.TargetUrl = url.OptimizeUrl(); Log.Info("Automatically determine target url '{0}'", context.TargetUrl); } } } } } if (!string.IsNullOrEmpty(context.TargetUrl)) { context.Provider = providerManager.GetProvider(context.TargetUrl); } return(context); }
public static Config Validate(Config config) { var currentVersion = ServiceLocator.Current.GetInstance <IVersionService>().Version.ToString(); if (string.IsNullOrEmpty(config.LastVersion)) { config.LastVersion = currentVersion; } if (string.IsNullOrEmpty(config.InstallPath)) { config.InstallPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } if (string.IsNullOrEmpty(config.WorkingDirectory)) { config.WorkingDirectory = @"C:\Work"; } if (string.IsNullOrEmpty(config.WhatsNewSeenForVersion)) { config.WhatsNewSeenForVersion = currentVersion; } if (config.Repositories == null) { config.Repositories = new Repository[0]; } if (config.Repositories.Any(r => r.Platform == null)) { config.Repositories = config.Repositories.Where(r => r.Platform != null).ToArray(); } var reposToDownload = new List <Repository>(); var reposOutdated = new List <Repository>(); foreach (var platform in ServiceLocator.Current.GetInstance <IPlatformProvider>().PlatformInfos) { var conigRepos = config.Repositories.Where(r => r.Platform == platform.Name); var repoVersions = RepositoryLoader.GetVersions(platform); foreach (var version in repoVersions) { if (conigRepos.Select(r => r.Version).Contains(version)) { continue; } reposToDownload.Add(Repository.CreateRegular(platform.Name, version, Path.Combine(config.WorkingDirectory, platform.LocalPath, version))); } foreach (var repo in conigRepos) { if (!repoVersions.Contains(repo.Version)) { reposOutdated.Add(repo); } } } var repos = config.Repositories.ToList(); repos.RemoveAll(reposOutdated.Contains); config.Repositories = repos.ToArray(); if (reposToDownload.Count > 0) { config.Repositories = config.Repositories.Concat(reposToDownload).ToArray(); } return(config); }