コード例 #1
0
        public void GetLocalVersionCommandLine()
        {
            var provider = new VaultVersionControlProvider(@"C:\Program Files\SourceGear\Vault Client\vault.exe");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                Operation = VersionControlOperation.GetLocalVersion,
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "SourcePath\\FileName.ext"
            };

            var result = provider.BuildCommandLineArguments(args);

            Assert.AreEqual("listfolder -host \"Server:Port\" -user \"Username\" -password \"Password\" -repository \"ProjectName\" \"$SourcePath\"", result);
        }
コード例 #2
0
        public void GetSourceIndexForFile()
        {
            var provider = new VaultVersionControlProvider("%VCS_EXECUTABLE%");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                DestinationPath = @"D:\Source\",
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "$/ProjectName/SourcePath",
                Label = "My Label"
            };
            var indexer = new SourceIndexer(provider, args);

            Assert.AreEqual(@"D:\Source\ProjectName\SourcePath\File.ext*/ProjectName/SourcePath*My Label", indexer.GetVersionIndexForFile(@"d:\Source\ProjectName\SourcePath\File.ext"), ignoreCase: true);
            Assert.AreEqual(@"D:\Source\ProjectName\SourcePath\File.ext*/ProjectName/SourcePath*My Label", indexer.GetVersionIndexForFile(@"D:\Source\ProjectName\SourcePath\File.ext"), ignoreCase: true);
        }
コード例 #3
0
        public void GetVersionCommandForFile()
        {
            var provider = new VaultVersionControlProvider("%VCS_EXECUTABLE%");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                DestinationPath = @"D:\Source",
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "$/SourcePath",
                Label = "My Label"
            };
            var indexer = new SourceIndexer(provider, args);

            var command = indexer.GetVersionCommand();

            Assert.AreEqual("\"%VCS_EXECUTABLE%\" getlabel -host \"%VCS_SERVER%\" -user \"%VCS_USERNAME%\" -password \"%VCS_PASSWORD%\" -repository \"%VCS_PROJECT%\" -destpath \"%TARG%\\%VAR3%%fnbksl%(%VAR2%)\" \"$%VAR2%/%fnfile%(%VAR1%)\" \"%VAR3%\"", command, ignoreCase: true);
        }
コード例 #4
0
        public void BuildCommandLineArguments_for_get_specific_version()
        {
            var provider = new VaultVersionControlProvider(@"C:\Program Files\SourceGear\Vault Client\vault.exe");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                DestinationPath = "DestinationPath",
                Operation = VersionControlOperation.Get,
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "SourcePath",
                Version = "50"
            };

            var result = provider.BuildCommandLineArguments(args);

            Assert.AreEqual("getversion -host \"Server:Port\" -user \"Username\" -password \"Password\" -repository \"ProjectName\" 50 \"$SourcePath\" \"DestinationPath\"", result);
        }
コード例 #5
0
        public void GetLocalVersion()
        {
            var provider = new VaultVersionControlProvider(@"C:\Program Files\SourceGear\Vault Client\vault.exe");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                Operation = VersionControlOperation.GetLocalVersion,
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "SourcePath\\UnchangedFile.cs"
            };

            var process = new Mock<IProcessResult>();
            process.Setup(process1 => process1.StandardOutput).Returns(VaultTestResponses.ListFolderResponse);

            var result = provider.ParseResult(args, process.Object);

            Assert.AreEqual(ServiceResultCode.Success, result.ResultCode);
            Assert.AreEqual(6, result.ResultValue);
        }
コード例 #6
0
        /// <summary>
        /// When overridden in a derived class, executes the task.
        /// </summary>
        /// <returns>
        /// <c>true</c> if the task successfully executed; otherwise, <c>false</c>.
        /// </returns>
        public override bool Execute()
        {
            // Get the version control arguments, which are in the form of a URI
            var uri = new Uri(VersionControlArguments);

            if( Symbols == null )
            {
                Log.LogWarning("No symbol files passed to index");
                return true;
            }

            var vaultExecutable = VcsExecutablePath;

            var args = VersionControlArgumentsConverter.FromUri(uri);

            foreach (var item in Symbols)
            {
                var path = item.GetMetadata("FullPath");

                Log.LogMessage("Indexing source in file: {0}", path);

                var srcTool = new SrcTool(path);

                // Obtain a list of source files to index
                var files = srcTool.GetSourceFiles();
                files.ForEach( file => Log.LogMessage(MessageImportance.Low, "Source file: {0}", file) );

                // We'll write the SrcSrv stream to a temporary file, and that
                // will be passed to write to the debug symbols.
                var sb = new StringBuilder();

                var provider = new VaultVersionControlProvider(vaultExecutable);

                var indexer = new SourceIndexer(provider, args);

                sb.Append(indexer.GetIniBlock());
                sb.Append(indexer.GetVariableBlock());

                sb.AppendLine("SRCSRV: source files ---------------------------------------");

                var indexedFiles = files.Select(indexer.GetVersionIndexForFile).Where(line => !line.IsNullOrEmpty());

                // If we didn't manage to index any files, then move on to the next file
                if( indexedFiles.Count() == 0)
                {
                    Log.LogMessage("No files found to map against version control");
                    continue;
                }

                // Write out any successfully indexed files
                foreach (var line in indexedFiles )
                {
                    sb.AppendLine(line);
                }

                // Done indexing source
                sb.AppendLine("SRCSRV: end ------------------------------------------------");

                var lines = sb.ToString().Trim();

                Log.LogMessage(MessageImportance.Low, lines);

                // Write the stream to a temp file, which we can pass
                // to PdbStr);
                using (var temp = new TempFile())
                {
                    temp.WriteAllText(lines);

                    // Write the stream to the debug symbols
                    using (var pdbStr = new PdbStr())
                    {
                        pdbStr.PdbFileName = path;
                        pdbStr.StreamFileName = temp.FileInfo.FullName;
                        pdbStr.StreamName = "srcsrv";
                        pdbStr.Operation = PdbStrOperation.Write;

                        if(!pdbStr.Start()) throw new FoundationException("Couldn't start PdbStr: {0}", pdbStr.StartInfo.FileName);

                        var result = new ProcessResult(pdbStr);

                        pdbStr.WaitForExit();

                        var output = result.StandardOutput;

                        if (output.ContainsCaseInsensitive("error"))
                        {
                            Log.LogError(output);
                        }
                        else
                        {
                            Log.LogMessage(output);
                        }

                    }
                }

            }

            return true;
        }
コード例 #7
0
        public void Get_for_label()
        {
            var provider = new VaultVersionControlProvider(@"C:\Program Files\SourceGear\Vault Client\vault.exe");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                DestinationPath = @"C:\DestinationPath\",
                Operation = VersionControlOperation.Get,
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "/SourcePath/FileName.ext",
                Label = "My Label"
            };

            var result = provider.BuildCommandLineArguments(args);

            Assert.AreEqual("getlabel -host \"Server:Port\" -user \"Username\" -password \"Password\" -repository \"ProjectName\" -destpath \"C:\\DestinationPath\" \"$SourcePath/FileName.ext\" \"My Label\"", result);
        }
コード例 #8
0
        public void MapVersionControlSourcePath()
        {
            var provider = new VaultVersionControlProvider(@"C:\Program Files\SourceGear\Vault Client\vault.exe");

            var args = new VersionControlArguments
            {
                Credentials = new NetworkCredential("Username", "Password"),
                DestinationPath = "C:\\WorkingFolder",
                Operation = VersionControlOperation.Get,
                Project = "ProjectName",
                Provider = "Vault",
                Server = "Server:Port",
                SourcePath = "SourcePath\\FileName.ext",
                Label = "My Label"
            };

            Assert.IsNull(provider.MapVersionControlSourcePath("D:\\WorkingFolder", args));
            Assert.AreEqual("/Folder", provider.MapVersionControlSourcePath(@"C:\WorkingFolder\Folder\File.ext", args));
            Assert.AreEqual("/Folder", provider.MapVersionControlSourcePath(@"C:\workingFolder/Folder\File.ext", args));
        }