Exemplo n.º 1
0
        public static SnapshotTaken TakeSnapshot(string name, IEnumerable <string> includedPaths, IEnumerable <string> excludedNames, bool verbose)
        {
            var recorder = new SnapshotTaken(name, includedPaths, excludedNames ?? new String[0], verbose);

            recorder.Take();
            return(recorder);
        }
Exemplo n.º 2
0
        public void View(
            [Required]
            [Description("Comma separated list of files to be parsed during snapshot creation. Wildcards are accepted.")]
            string[] include,
            [Description("Comma separated list of files to be excluded during snapshot creation. Only specify file names, not paths. Wildcards are accepted.")]
            [Aliases("x")]
            string[] exclude
            )
        {
            var snapshot = SnapshotTaken.TakeSnapshot("ActualSnapshot", include, exclude ?? new string[0], _verbose);

            Console.WriteLine("Actual snapshot contains:");
            foreach (var serializerInfo in snapshot.Snapshot.DefaultSerializers.OrderBy(item => item.TypeFullName))
            {
                Console.WriteLine("{0} => {1}[{2}]", serializerInfo.TypeFullName, serializerInfo.PackformatName, serializerInfo.Version);
            }
        }
Exemplo n.º 3
0
        public void Add(
            [Required]
            [Description("The name of the snapshot")]
            string name,
            [Required]
            [Description("Comma separated list of files to be parsed during snapshot creation. Wildcards are accepted.")]
            string[] include,
            [Description("Comma separated list of files to be excluded during snapshot creation. Only specify file names, not paths. Wildcards are accepted.")]
            [Aliases("x")]
            string[] exclude,
            [Description("If specified the snapshot won't be saved to the snapshot file.")]
            [DefaultValue(false)]
            bool whatif,
            [Description("If specified the snapshot will replace an existing one with the same name (Use only in special cases to fixup messed snapshots).")]
            [DefaultValue(false)]
            bool replace)
        {
            var path            = GetSnapshotPath();
            var snapshotHistory = System.IO.File.Exists(path) ? SnapshotHistory.LoadFrom(path) : SnapshotHistory.Empty;

            var snapshot = SnapshotTaken.TakeSnapshot(name, include, exclude ?? new string[0], _verbose);

            Console.WriteLine("Assemblies parsed:");
            snapshot.AssembliesParsed.ForEach(Console.WriteLine);

            if (replace)
            {
                snapshotHistory.ReplaceSnapshot(snapshot.Snapshot);
            }
            else
            {
                snapshotHistory.AddSnapshot(snapshot.Snapshot);
            }

            if (!whatif)
            {
                snapshotHistory.SaveTo(path);
                Console.WriteLine("Snapshot taken.");
            }
        }
Exemplo n.º 4
0
        public void Compare(
            [Required]
            [Description("Comma separated list of files to be parsed during snapshot creation. Wildcards are accepted.")]
            string[] include,
            [Description("Comma separated list of files to be excluded during snapshot creation. Only specify file names, not paths. Wildcards are accepted.")]
            [Aliases("x")]
            string[] exclude,
            [Description("Defines the name of the oldest snapshot taken into account.")]
            string oldestSnapshot,
            [Description("Returns with exit code 1 if there is a difference between the snapshots.")]
            [Aliases("failOnDifference")]
            bool haltOnDifference)
        {
            var path = GetSnapshotPath();

            if (!System.IO.File.Exists(path))
            {
                throw new ApplicationException(String.Format("Snapshot file on path {0} not found.", path));
            }
            var history  = SnapshotHistory.LoadFrom(path);
            var snapshot = SnapshotTaken.TakeSnapshot("ActualSnapshot", include, exclude ?? new string[0], _verbose);

            var snapshotsToCheckAgainst = oldestSnapshot != null
                ? history.SkipWhile(snp => !snp.Name.Equals(oldestSnapshot, StringComparison.InvariantCultureIgnoreCase))
                : history;

            var difference = snapshot.Snapshot.CompareToBase(snapshotsToCheckAgainst);

            Console.WriteLine("The following differences are detected:");
            Console.WriteLine(difference.GetHumanReadableResult(_verbose));

            if (haltOnDifference)
            {
                Environment.Exit(1);
            }
        }