コード例 #1
0
        public static void NoCommits(string buildMetadata, string expectedVersion, string path, Version actualVersion)
        {
            $"Given an empty git repository in {path = MethodBase.GetCurrentMethod().GetTestDirectory(buildMetadata)}"
            .x(() => EnsureEmptyRepository(path));

            $"When the version is determined using build metadata '{buildMetadata}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, buildMetadata, default, default, default));
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CancelledOrderRule"/> class.
 /// </summary>
 /// <param name="parameters">
 /// The parameters.
 /// </param>
 /// <param name="operationContext">
 /// The operation context.
 /// </param>
 /// <param name="alertStream">
 /// The alert stream.
 /// </param>
 /// <param name="orderFilter">
 /// The order filter.
 /// </param>
 /// <param name="equityMarketCacheFactory">
 /// The market cache factory.
 /// </param>
 /// <param name="fixedIncomeMarketCacheFactory">
 /// The market cache factory.
 /// </param>
 /// <param name="runMode">
 /// The run mode.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 /// <param name="tradingHistoryLogger">
 /// The trading history logger.
 /// </param>
 public CancelledOrderRule(
     ICancelledOrderRuleEquitiesParameters parameters,
     ISystemProcessOperationRunRuleContext operationContext,
     IUniverseAlertStream alertStream,
     IUniverseOrderFilter orderFilter,
     IUniverseEquityMarketCacheFactory equityMarketCacheFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory,
     RuleRunMode runMode,
     ILogger <CancelledOrderRule> logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
     : base(
         parameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromMinutes(60),
         parameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromMinutes(60),
         parameters?.Windows?.FutureWindowSize ?? TimeSpan.Zero,
         Rules.CancelledOrders,
         Versioner.Version(2, 0),
         "Cancelled Order Rule",
         operationContext,
         equityMarketCacheFactory,
         fixedIncomeMarketCacheFactory,
         runMode,
         logger,
         tradingHistoryLogger)
 {
     this.parameters       = parameters ?? throw new ArgumentNullException(nameof(parameters));
     this.operationContext = operationContext ?? throw new ArgumentNullException(nameof(operationContext));
     this.alertStream      = alertStream ?? throw new ArgumentNullException(nameof(alertStream));
     this.orderFilter      = orderFilter ?? throw new ArgumentNullException(nameof(orderFilter));
     this.logger           = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #3
0
        public static void NoCommits(string path, Version actualVersion)
        {
            $"Given an empty git repository in {path = MethodBase.GetCurrentMethod().GetTestDirectory()}"
            .x(() => EnsureEmptyRepository(path));

            "When the version is determined using minimum major minor '1.2'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, new MajorMinor(1, 2), default, default, default, default));
コード例 #4
0
        public static void DefaultPreReleasePhase(string phase, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory($"default-pre-release-phase-{phase}")}'"
            .x(() => EnsureEmptyRepositoryAndCommit(path));

            $"When the version is determined using the default pre-release phase '{phase}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, default, phase, new TestLogger()));
コード例 #5
0
ファイル: Versioning.cs プロジェクト: thefringeninja/min-ver
        public static void RepoWithHistory(string name, string path)
        {
            $"Given a git repository in '{path = GetScenarioDirectory("versioning-repo-with-history-" + name)}' with a history of branches and/or tags"
            .x(async() =>
            {
                await EnsureRepositoryWithACommit(path);

                foreach (var command in historicalCommands[name].Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var nameAndArgs = command.Split(" ", 2);
                    await RunAsync(nameAndArgs[0], nameAndArgs[1], path);
                    await Task.Delay(200);
                }
            });

            "When the version is determined for every commit"
            .x(() =>
            {
                var versionCounts = new Dictionary <string, int>();

                using (var repo = new Repository(path))
                {
                    foreach (var commit in repo.Commits)
                    {
                        Commands.Checkout(repo, commit);

                        var version       = Versioner.GetVersion(path, default, default, default, default, default);
コード例 #6
0
        public static void DefaultPreReleasePhase(string phase, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in {path = MethodBase.GetCurrentMethod().GetTestDirectory(phase)}"
            .x(() => EnsureEmptyRepositoryAndCommit(path));

            $"When the version is determined using the default pre-release phase '{phase}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, default, phase, default));
コード例 #7
0
        public static void NoCommits(string path, Repository repo, Version actualVersion)
        {
            $"Given an empty git repository in '{path = GetScenarioDirectory($"minimum-major-minor-not-tagged")}'"
            .x(c => repo = EnsureEmptyRepository(path).Using(c));

            "When the version is determined using minimum major minor '1.2'"
            .x(() => actualVersion = Versioner.GetVersion(repo, default, new MajorMinor(1, 2), default, new TestLogger()));
コード例 #8
0
        public static void NoCommits(string buildMetadata, string expectedVersion, string path, Version actualVersion)
        {
            $"Given an empty git repository in '{path = GetScenarioDirectory($"build-metadata-no-tag-{buildMetadata}")}'"
            .x(c => EnsureEmptyRepository(path).Using(c));

            $"When the version is determined using build metadata '{buildMetadata}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, buildMetadata, default, new TestLogger()));
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeWashTradeRule"/> class.
 /// </summary>
 /// <param name="parameters">
 /// The parameters.
 /// </param>
 /// <param name="orderFilterService">
 /// The order filter service.
 /// </param>
 /// <param name="ruleContext">
 /// The rule context.
 /// </param>
 /// <param name="equityFactory">
 /// The factory.
 /// </param>
 /// <param name="fixedIncomeFactory">
 /// The factory.
 /// </param>
 /// <param name="runMode">
 /// The run mode.
 /// </param>
 /// <param name="alertStream">
 /// The alert stream.
 /// </param>
 /// <param name="clusteringService">
 /// The clustering service.
 /// </param>
 /// <param name="portfolioFactory">
 /// The portfolio factory.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 /// <param name="tradingStackLogger">
 /// The trading stack logger.
 /// </param>
 public FixedIncomeWashTradeRule(
     IWashTradeRuleFixedIncomeParameters parameters,
     IUniverseFixedIncomeOrderFilterService orderFilterService,
     ISystemProcessOperationRunRuleContext ruleContext,
     IUniverseEquityMarketCacheFactory equityFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeFactory,
     RuleRunMode runMode,
     IUniverseAlertStream alertStream,
     IClusteringService clusteringService,
     IPortfolioFactory portfolioFactory,
     ILogger <FixedIncomeWashTradeRule> logger,
     ILogger <TradingHistoryStack> tradingStackLogger)
     : base(
         parameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromDays(1),
         parameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromDays(1),
         parameters?.Windows?.FutureWindowSize ?? TimeSpan.Zero,
         Rules.FixedIncomeWashTrades,
         Versioner.Version(1, 0),
         $"{nameof(FixedIncomeWashTradeRule)}",
         ruleContext,
         equityFactory,
         fixedIncomeFactory,
         runMode,
         logger,
         tradingStackLogger)
 {
     this.parameters         = parameters ?? throw new ArgumentNullException(nameof(parameters));
     this.orderFilterService = orderFilterService ?? throw new ArgumentNullException(nameof(orderFilterService));
     this.alertStream        = alertStream ?? throw new ArgumentNullException(nameof(alertStream));
     this.clusteringService  = clusteringService ?? throw new ArgumentNullException(nameof(clusteringService));
     this.portfolioFactory   = portfolioFactory ?? throw new ArgumentNullException(nameof(portfolioFactory));
     this.logger             = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #10
0
        public override void Execute()
        {
            if (Debugger.IsAttached)
            {
                return;
            }

            var scheduledForAutoPublish = Finder
                                          .Where.Detail("FuturePublishDate").Lt(DateTime.Now)
                                          .PreviousVersions(VersionOption.Include).Select();

            for (int i = 0; i < scheduledForAutoPublish.Count; i++)
            {
                // Get the relevant versions
                var scheduledVersion = scheduledForAutoPublish[i];
                var masterVersion    = scheduledVersion.VersionOf;
                // Removing the DelayPublishingUntil Date so that it won't get picked up again
                scheduledVersion["FuturePublishDate"] = null;

                try
                {
                    Security.ScopeEnabled = false;
                    if (masterVersion == null)
                    {
                        Persister.Save(scheduledVersion);
                    }
                    else
                    {
                        Versioner.ReplaceVersion(masterVersion, scheduledVersion, true);
                    }
                }
                finally
                {
                    Security.ScopeEnabled = true;
                }
            }

            var implicitAutoPublish = Finder
                                      .Where.Published.Le(Utility.CurrentTime())
                                      .And.State.Eq(ContentState.Waiting)
                                      .Select();

            for (int i = 0; i < implicitAutoPublish.Count; i++)
            {
                try
                {
                    Security.ScopeEnabled = false;
                    // saving the master version for auto-publish will be eventually become published without this, but we want to update the state
                    var item = implicitAutoPublish[i];
                    item.State = ContentState.Published;
                    Persister.Save(item);
                }
                finally
                {
                    Security.ScopeEnabled = true;
                }
            }
        }
コード例 #11
0
ファイル: BuildMetadata.cs プロジェクト: Roman-Blinkov/minver
        public static async Task NoCommits(string buildMetadata, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory(buildMetadata);

            await EnsureEmptyRepository(path);

            // act
            var actualVersion = Versioner.GetVersion(path, "", MajorMinor.Zero, buildMetadata, default, "", NullLogger.Instance);
コード例 #12
0
ファイル: MinMajorMinor.cs プロジェクト: Roman-Blinkov/minver
        public static async Task NoCommits()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();

            await EnsureEmptyRepository(path);

            // act
            var actualVersion = Versioner.GetVersion(path, "", new MajorMinor(1, 2), "", default, "", NullLogger.Instance);
コード例 #13
0
        public static async Task DefaultPreReleasePhase(string phase, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory(phase);

            await EnsureEmptyRepositoryAndCommit(path);

            // act
            var actualVersion = Versioner.GetVersion(path, "", MajorMinor.Zero, "", default, phase, NullLogger.Instance);
コード例 #14
0
ファイル: TagPrefixes.cs プロジェクト: thefringeninja/min-ver
        public static void TagPrefix(string tag, string prefix, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory($"tag-prefixes-{tag}")}'"
            .x(async() => await EnsureRepositoryWithACommit(path));

            $"And the commit is tagged '{tag}'"
            .x(async() => await RunAsync("git", $"tag {tag}", path));

            $"When the version is determined using the tag prefix '{prefix}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, prefix, default, default, default));
コード例 #15
0
        public static async Task TagPrefix(string tag, string prefix, string expectedVersion)
        {
            // act
            var path = MethodBase.GetCurrentMethod().GetTestDirectory((tag, prefix));

            await EnsureEmptyRepositoryAndCommit(path);
            await Tag(path, tag);

            // act
            var actualVersion = Versioner.GetVersion(path, prefix, MajorMinor.Zero, "", default, "", NullLogger.Instance);
コード例 #16
0
        public static void CurrentTag(string tag, string buildMetadata, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory($"build-metadata-current-tag-{tag}-{buildMetadata}")}'"
            .x(async() => await EnsureRepositoryWithACommit(path));

            $"And the commit is tagged '{tag}'"
            .x(async() => await RunAsync("git", $"tag {tag}", path));

            $"When the version is determined using build metadata '{buildMetadata}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, default, buildMetadata));
コード例 #17
0
        public static void TagPrefix(string tag, string prefix, string expectedVersion, string path, Repository repo, Version actualVersion)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory($"tag-prefixes-{tag}")}'"
            .x(c => repo = EnsureEmptyRepositoryAndCommit(path).Using(c));

            $"And the commit is tagged '{tag}'"
            .x(() => repo.ApplyTag(tag));

            $"When the version is determined using the tag prefix '{prefix}'"
            .x(() => actualVersion = Versioner.GetVersion(path, prefix, default, default, new TestLogger()));
コード例 #18
0
ファイル: TagPrefixes.cs プロジェクト: 0xced/minver
        public static void TagPrefix(string tag, string prefix, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in {path = MethodBase.GetCurrentMethod().GetTestDirectory(tag)}"
            .x(() => EnsureEmptyRepositoryAndCommit(path));

            $"And the commit is tagged '{tag}'"
            .x(() => Tag(path, tag));

            $"When the version is determined using the tag prefix '{prefix}'"
            .x(() => actualVersion = Versioner.GetVersion(path, prefix, default, default, default, default, default));
コード例 #19
0
        public void ShouldIgnoreWhenFileNotFound()
        {
            var resolver     = new FileResolver();
            var mockedEditor = new Mock <IFileEditor>();

            mockedEditor.Setup(o => o.Edit(It.IsAny <string>(), It.IsAny <IEnumerable <Release> >()));
            var sut = new Versioner(resolver, mockedEditor.Object);

            sut.ApplyTo("");
            mockedEditor.Verify(o => o.Edit(string.Empty, null), Times.Never);
        }
コード例 #20
0
        public bool Execute(IDbConnectionProvider conn, MigrationResources resources)
        {
            _logger.Info("Initialize database versioner");
            var versioner = new Versioner(conn, new Logger <Version>());

            _logger.Info("Initialize executor");
            var executor = new Executor(conn, versioner, new Logger <Executor>());

            _logger.Info("Execute migrations");
            return(executor.Execute(resources));
        }
コード例 #21
0
        public bool Execute(ISession session, MigrationResources resources)
        {
            _logger.Debug("Initialize database versioner");
            var versioner = new Versioner(session, new Logger <Version>());

            _logger.Debug("Initialize executor");
            var executor = new Executor(session, versioner, new Logger <Executor>());

            _logger.Debug("Execute migrations");
            return(executor.Execute(resources));
        }
コード例 #22
0
        public static async Task RepoWithHistory(int minMajor, int minMinor)
        {
            // arrange
            var minMajorMinor = new MajorMinor(minMajor, minMinor);

            var historicalCommands =
                @"
git commit --allow-empty -m '.'
git tag not-a-version
git checkout -b foo
git commit --allow-empty -m '.'
git tag 1.0.0-foo.1
git checkout main
git merge foo --no-edit --no-ff
git checkout -b bar
git commit --allow-empty -m '.'
git checkout main
git checkout -b baz
git commit --allow-empty -m '.'
git checkout main
git merge bar baz --no-edit --no-ff --strategy=octopus
";

            var path = MethodBase.GetCurrentMethod().GetTestDirectory(minMajorMinor);

            await EnsureEmptyRepository(path);

            foreach (var item in historicalCommands
                     .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                     .Select((command, index) => new { Command = command, Index = $"{index}" }))
            {
                if (item.Command.StartsWith("git commit", StringComparison.Ordinal))
                {
                    // Sometimes git seems to treat bar and baz as a single branch if the commits are empty.
                    // This probably occurs during the octopus merge.
                    // So let's add a file before each commit to ensure that doesn't happen.
                    await File.WriteAllTextAsync(Path.Combine(path, item.Index), item.Index);

                    _ = await ReadAsync("git", $"add {item.Index}", path);

                    // if not enough delay is given between commits,
                    // the order of parallel commits on different branches seems to be non-deterministic
                    await Task.Delay(1100);
                }

                var nameAndArgs = item.Command.Split(" ", 2);
                _ = await ReadAsync(nameAndArgs[0], nameAndArgs[1], path);
            }

            var log = new TestLogger();

            // act
            _ = Versioner.GetVersion(path, "", minMajorMinor, "", default, "", log);
コード例 #23
0
        public static void RtmVersionIncrement(string tag, VersionPart autoIncrement, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in {path = MethodBase.GetCurrentMethod().GetTestDirectory(autoIncrement)}"
            .x(() => EnsureEmptyRepositoryAndCommit(path));

            $"And the commit is tagged '{tag}'"
            .x(() => Tag(path, tag));

            "And another commit"
            .x(() => Commit(path));

            $"When the version is determined using auto-increment '{autoIncrement}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, autoIncrement, default, default));
コード例 #24
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Provide a path to your solution");
                return;
            }

            var settings  = PlainTextReader.From(args[0] + "\\VersionedFiles.txt").DelimitBy(ColumnDelimiter.Pipe).GetAListOf <VersionedFile>();
            var versioner = new Versioner(new FileResolver(), new FilePropertyEditor(settings));

            versioner.ApplyTo(args[0]);
        }
コード例 #25
0
        public static void RtmVersionIncrement(string tag, VersionPart autoIncrement, string expectedVersion, string path, Repository repo, Version actualVersion)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory($"rtm-auto-increment-{tag}")}'"
            .x(c => repo = EnsureEmptyRepositoryAndCommit(path).Using(c));

            $"And the commit is tagged '{tag}'"
            .x(() => repo.ApplyTag(tag));

            $"And another commit"
            .x(() => Commit(path));

            $"When the version is determined using auto-increment '{autoIncrement}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, autoIncrement, default, new TestLogger()));
コード例 #26
0
        public static void Subdirectory(string path, Version version)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory("msbuild-integration-subdirectory")}'"
            .x(async() => await EnsureRepositoryWithACommit(path));

            "And the commit is tagged 2.0.0"
            .x(async() => await RunAsync("git", "tag 2.0.0", path));

            "And the repository has a subdirectory"
            .x(() => EnsureEmptyDirectory(path = Path.Combine(path, "subdirectory")));

            "When the version is determined using the subdirectory"
            .x(() => version = Versioner.GetVersion(path, default, default, default, default, default));
コード例 #27
0
        public void ShouldIgnoreWhenEmptyFile()
        {
            var releases       = new Release[0];
            var mockedResolver = new Mock <ISourceResolver>();

            mockedResolver.Setup(o => o.Resolve(It.IsAny <string>())).Returns(releases);
            var mockedEditor = new Mock <IFileEditor>();

            mockedEditor.Setup(o => o.Edit(It.IsAny <string>(), It.IsAny <IEnumerable <Release> >()));
            var sut = new Versioner(mockedResolver.Object, mockedEditor.Object);

            sut.ApplyTo("anyPath");
            mockedEditor.Verify(o => o.Edit(string.Empty, null), Times.Never);
        }
コード例 #28
0
        public void ShouldApplyVersionToScenario1()
        {
            var settings = new List <VersionedFile>
            {
                new VersionedFile {
                    FileName = "AssemblyInfo.cs",
                    Preffix  = @"[assembly: AssemblyVersion(""",
                    Suffix   = @""")]"
                }
            };
            var sut = new Versioner(new FileResolver(), new FilePropertyEditor(settings));

            sut.ApplyTo(@"..\\..\\scenario1");
        }
コード例 #29
0
ファイル: AutoIncrement.cs プロジェクト: Roman-Blinkov/minver
        public static async Task RtmVersionIncrement(string tag, VersionPart autoIncrement, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory((tag, autoIncrement));

            await EnsureEmptyRepositoryAndCommit(path);
            await Tag(path, tag);
            await Commit(path);

            // act
            var actualVersion = Versioner.GetVersion(path, "", MajorMinor.Zero, "", autoIncrement, "", NullLogger.Instance);

            // assert
            Assert.Equal(expectedVersion, actualVersion.ToString());
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: thefringeninja/min-ver
        static int Main(string[] args)
        {
            var app = new CommandLineApplication();

            app.HelpOption();

            var buildMetadata = app.Option("-b|--build-metadata <BUILD_METADATA>", "The build metadata to append to the version.", CommandOptionType.SingleValue);
            var majorMinor    = app.Option("-m|--major-minor <MAJOR.MINOR>", "The MAJOR.MINOR version range. E.g. '2.0'.", CommandOptionType.SingleValue);
            var path          = app.Option("-p|--path <PATH>", "The path of the repository.", CommandOptionType.SingleValue);
            var tagPrefix     = app.Option("-t|--tag-prefix <TAG_PREFIX>", "The tag prefix.", CommandOptionType.SingleValue);
            var verbose       = app.Option("-v|--verbose", "Enable verbose logging.", CommandOptionType.NoValue);

            app.OnExecute(() =>
            {
                var major = 0;
                var minor = 0;

                var majorMinorValue = majorMinor.Value();

                if (!string.IsNullOrEmpty(majorMinorValue))
                {
                    var numbers = majorMinorValue.Split('.');

                    if (numbers.Length > 2)
                    {
                        Console.Out.WriteLine($"MinVer: error MINVER0004 : More than one dot in MAJOR.MINOR range '{majorMinorValue}'.");
                        return(2);
                    }

                    if (!int.TryParse(numbers[0], out major))
                    {
                        Console.Out.WriteLine($"MinVer: error MINVER0005 : Invalid MAJOR '{numbers[0]}' in MAJOR.MINOR range '{majorMinorValue}'.");
                        return(2);
                    }

                    if (numbers.Length > 1 && !int.TryParse(numbers[1], out minor))
                    {
                        Console.Out.WriteLine($"MinVer: error MINVER0006 : Invalid MINOR '{numbers[1]}' in MAJOR.MINOR range '{majorMinorValue}'.");
                        return(2);
                    }
                }

                Console.Out.WriteLine(Versioner.GetVersion(path.Value() ?? ".", verbose.HasValue(), tagPrefix.Value(), major, minor, buildMetadata.Value()));
                return(0);
            });

            return(app.Execute(args));
        }
コード例 #31
0
ファイル: ShaMap.cs プロジェクト: sublimator/ripple-dot-net
 public ShaMap() : base(0)
 {
     // This way we can copy the first to the second,
     // copy the second, then copy the first again ;)
     _copies = new Versioner();
 }