public static void Log(IServerPath path, string msg)
    {
        //add parameter checking here

        string path = path.MapPath("file.txt");
        //actual log goes here
    }
Exemplo n.º 2
0
        private void Branch(IServerPath sourceServerPath, IServerPath targetServerPath, bool createBranchObject, VersionSpec versionSpec)
        {
            var server = this.VersionControlServer;

            server.CreateBranch(sourceServerPath.AsString(),
                                targetServerPath.AsString(),
                                versionSpec,
                                null,
                                "Branch from " + sourceServerPath.AsString(),
                                null,
                                null,
                                new Mapping[0]
                                );


            if (createBranchObject)
            {
                var itemIdentifier = new ItemIdentifier(targetServerPath.AsString());
                if (!server.QueryBranchObjects(itemIdentifier, RecursionType.None).Any())
                {
                    server.CreateBranchObject(new BranchProperties(itemIdentifier));
                }
            }

            _tfsCache.Refresh();
        }
Exemplo n.º 3
0
 public IServerPath ResolveDistributionServerPath(IServerPath basePath)
 {
     return(basePath.Subpath(Folders.EnginesAndGamesFolder.WellKnownName)
            .Subpath(_contentProvider.Name)
            .Subpath(Folders.EngineFolder.WellKnownName)
            .Subpath(_version.ToString()));
 }
Exemplo n.º 4
0
        internal IEnumerable <Changeset> GetCachedChangeSets(IServerPath serverPath)
        {
            var path = serverPath.AsString();

            return(_changeSets.Where(cs => cs.Changes.Any(change => change.Item.ServerItem.StartsWith(path, StringComparison.OrdinalIgnoreCase)))
                   .ToList());
        }
Exemplo n.º 5
0
        public void DownloadFolderContent(IServerPath serverPath, ILocalPath localPath, ILogger logger)
        {
            var items = this.VersionControlServer.GetItems(serverPath.AsString(), VersionSpec.Latest, RecursionType.OneLevel);

            foreach (var item in items.Items)
            {
                if (0 == string.Compare(item.ServerItem, serverPath.AsString(), true))
                {
                    continue;
                }

                var itemServerPath = new ServerPath(item.ServerItem);
                var itemLocalPath  = localPath.Subpath(itemServerPath.GetName());

                if (item.ItemType == ItemType.File)
                {
                    logger.Info($"Download file {item.ServerItem} to {itemLocalPath.AsString()}");
                    item.DownloadFile(itemLocalPath.AsString());
                }
                else
                {
                    DownloadFolderContent(itemServerPath, itemLocalPath, logger);
                }
            }
        }
Exemplo n.º 6
0
 private void BranchComponent(string sourcePath, IServerPath targetPath, int changeSet)
 {
     _tfsGateway.Branch(_tfsGateway.CreateServerPath(sourcePath),
                        targetPath,
                        true,
                        changeSet);
 }
Exemplo n.º 7
0
 private IServerPath ResolveDistributionServerPath(IServerPath basePath)
 {
     return(basePath.Subpath(Folders.EnginesAndGamesFolder.WellKnownName)
            .Subpath(_engineName.ToString())
            .Subpath(Folders.GamesFolder.WellKnownName)
            .Subpath(_gameName)
            .Subpath(Folders.GameLimitsFolder.WellKnownName)
            .Subpath(_version.ToString()));
 }
Exemplo n.º 8
0
 public GameEngineDeployContent(string componentUniqueId,
                                string name,
                                VersionNumber version,
                                IServerPath projectServerPath,
                                IEnumerable <DeployableFileDefinition> files,
                                string componentDescription,
                                IServerPath distributionServerPath)
     : base(componentUniqueId, name, version, projectServerPath, files, componentDescription, distributionServerPath)
 {
 }
Exemplo n.º 9
0
 public BuildConfiguration(IServerPath ggpApprovalSystemSourceCodeFolder,
                           Optional <ILocalPath> installerRootDeliveryFolder,
                           BuildTaskInfo buildTaskInfo,
                           ISourceControlAdapter sourceControlAdapter)
 {
     this.GGPApprovalSystemSourceCodeFolder = ggpApprovalSystemSourceCodeFolder;
     _installerRootDeliveryFolder           = installerRootDeliveryFolder;
     _buildTaskInfo        = buildTaskInfo;
     _sourceControlAdapter = sourceControlAdapter;
 }
Exemplo n.º 10
0
 public HistoryCache(int changeSetId,
                     IServerPath serverPath,
                     IEnumerable <Changeset> changeSets,
                     HistoryCacheManager historyCacheManager)
 {
     _changeSetId         = changeSetId;
     _serverPath          = serverPath.AsString();
     _changeSets          = changeSets;
     _historyCacheManager = historyCacheManager;
 }
Exemplo n.º 11
0
        public Optional <IServerPath> TryGetSubFolder(IServerPath parentServerPath, string subfolderName)
        {
            var result = Optional <IServerPath> .None();

            var subfolderServerPath = parentServerPath.Subpath(subfolderName);

            _tfsCache.FindFolder(subfolderServerPath.AsString())
            .Do(item => result = Optional <IServerPath> .Some(subfolderServerPath));

            return(result);
        }
Exemplo n.º 12
0
        public IEnumerable <IMergeableChangeSet> GetMergeChangeSets(IServerPath targetFolder)
        {
            var changeSets = new List <IMergeableChangeSet>();

            foreach (var mergeCandidate in _tfsGateway.GetMergeCanditates(this.ServerPath, targetFolder))
            {
                changeSets.Add(new TfsMergeableChangeSet(mergeCandidate.Changeset, this, targetFolder));
            }

            return(changeSets);
        }
Exemplo n.º 13
0
 public CoreComponentDeployContent(string componentUniqueId,
                                   string name,
                                   VersionNumber version,
                                   IServerPath projectServerPath,
                                   Optional <CoreComponentCustomizationMetaData> customizationMetaData,
                                   IEnumerable <DeployableFileDefinition> files,
                                   string componentDescription,
                                   IServerPath distributionServerPath)
     : base(componentUniqueId, name, version, projectServerPath, files, componentDescription, distributionServerPath)
 {
     this.CustomizationMetaData = customizationMetaData;
 }
Exemplo n.º 14
0
        public IHistoryCache CreateCache(IServerPath serverPath, int sinceThisChangeSet)
        {
            var historyCache = new HistoryCache(sinceThisChangeSet,
                                                serverPath,
                                                _versionControlServer.QueryHistoryEx(serverPath.AsString(),
                                                                                     sinceThisChangeSet,
                                                                                     true)
                                                .ToList(),
                                                this);

            _historyCache.TryAdd(sinceThisChangeSet, historyCache);
            return(historyCache);
        }
Exemplo n.º 15
0
        public GetStatus MergeChangeSet(IServerPath sourceBranchServerPath, int changesetId, IServerPath targetBranchServerPath)
        {
            var changeSetVersionSpec = new ChangesetVersionSpec(changesetId);
            var result = GetWorkspace().Merge(sourceBranchServerPath.AsString(),
                                              targetBranchServerPath.AsString(),
                                              changeSetVersionSpec,
                                              changeSetVersionSpec,
                                              LockLevel.None,
                                              RecursionType.Full,
                                              MergeOptionsEx.Conservative);

            _tfsCache.Refresh();
            return(result);
        }
Exemplo n.º 16
0
        public GetStatus Merge(IServerPath sourceBranchServerPath, IServerPath targetBranchServerPath)
        {
            var result = GetWorkspace().Merge(sourceBranchServerPath.AsString(),
                                              targetBranchServerPath.AsString(),
                                              null,
                                              null,
                                              LockLevel.None,
                                              RecursionType.Full,
                                              MergeOptionsEx.Conservative);

            _tfsCache.Refresh();

            return(result);
        }
Exemplo n.º 17
0
        public string ReadTextFile(IServerPath serverPath)
        {
            var item = this.VersionControlServer.GetItem(serverPath.AsString());

            if (item.ItemType != ItemType.File)
            {
                throw new ArgumentException($"The path {serverPath.AsString()} is not a file path");
            }

            using (var stream = item.DownloadFile())
                using (var streamReader = new StreamReader(stream))
                {
                    return(streamReader.ReadToEnd());
                }
        }
Exemplo n.º 18
0
        public void UpdateFileContent(IServerPath fileServerPath, byte[] content)
        {
            var workspace = GetWorkspace();

            workspace.Get(new GetRequest(fileServerPath.AsString(), RecursionType.OneLevel, VersionSpec.Latest), GetOptions.GetAll);
            var fileLocalPath = workspace.GetLocalItemForServerItem(fileServerPath.AsString());

            workspace.PendEdit(fileLocalPath);

            _fileSystemManager.WriteFileContent(fileLocalPath, content);

            workspace.CheckInWithPolicyOverride($"Update file {fileServerPath}",
                                                new string[] { fileLocalPath },
                                                "This file was updated automatically by the GGP Developer Tool.");
        }
Exemplo n.º 19
0
        public Optional <IServerPath> TryGetFile(IServerPath parentFolderServerPath, string fileName)
        {
            var fileServerPath = parentFolderServerPath.Subpath(fileName);

            Optional <Item> tfsItem = _tfsCache.FindFile(fileServerPath.AsString());

            if (tfsItem.Any())
            {
                return(Optional <IServerPath> .Some(fileServerPath));
            }
            else
            {
                return(Optional <IServerPath> .None());
            }
        }
Exemplo n.º 20
0
 public ComponentDeployContent(string componentUniqueId,
                               string name,
                               VersionNumber version,
                               IServerPath projectServerPath,
                               IEnumerable <DeployableFileDefinition> files,
                               string componentDescription,
                               IServerPath distributionServerPath)
 {
     this.ComponentUniqueId = componentUniqueId;
     this.Name                   = name;
     this.Version                = version;
     this.ProjectServerPath      = projectServerPath.AsString();
     this.Files                  = files;
     this.ComponentDescription   = componentDescription;
     this.DistributionServerPath = distributionServerPath.AsString();
 }
Exemplo n.º 21
0
        public void CreateFile(IServerPath folderServerPath, string fileName, byte[] content)
        {
            var workspace      = GetWorkspace();
            var fileServerPath = folderServerPath.Subpath(fileName);
            var fileLocalPath  = workspace.GetLocalItemForServerItem(fileServerPath.AsString());

            _fileSystemManager.WriteFileContent(fileLocalPath, content);

            workspace.PendAdd(fileLocalPath);

            workspace.CheckInWithPolicyOverride($"Add file {fileName}",
                                                new string[] { fileLocalPath },
                                                "This file was automatically created by the GGP Developer Tool.");

            _tfsCache.AddFileToCache(fileServerPath.AsString());
        }
Exemplo n.º 22
0
        internal IEnumerable <Changeset> QueryHistory(IServerPath serverPath, int sinceThisChangeSet)
        {
            HistoryCache cache;

            if (_historyCache.TryGetValue(sinceThisChangeSet, out cache))
            {
                if (cache.HasCacheFor(serverPath))
                {
                    return(cache.GetCachedChangeSets(serverPath));
                }
            }

            return(_versionControlServer.QueryHistoryEx(serverPath.AsString(), sinceThisChangeSet)
                   .Where(cs => cs.Changes.Any(change => change.Item.ServerItem.StartsWith(serverPath.AsString())))
                   .ToList());
        }
Exemplo n.º 23
0
        private void AppendInstallerContent(InstallerDefinition installerDefinition, IServerPath branchServerPath)
        {
            var installerContentTxtPath = branchServerPath.Subpath(Constants.Versions)
                                          .Subpath(installerDefinition.Version.ToString())
                                          .Subpath(Constants.InstallerContentTxt);

            foreach (var keyValue in StringKeyValueCollection.Parse(_sourceControlAdapter.ReadTextFile(installerContentTxtPath)))
            {
                if (keyValue.Value.StartsWith("$/"))
                {
                    installerDefinition.Components.Add(new InstallerDefinition.ComponentDefinition(keyValue.Name, _sourceControlAdapter.CreateServerPath(keyValue.Value)));
                }
                else //backward compatibility with the installers up to 1.5.x
                {
                    installerDefinition.Components.Add(new InstallerDefinition.ComponentDefinition(keyValue.Name, _sourceControlAdapter.CreateServerPath(ConfigurationManager.AppSettings[ConfigurationKeys.oldDistributionPath]).Subpath(keyValue.Value)));
                }
            }
        }
Exemplo n.º 24
0
 public byte[] GetFileContent(IServerPath fileServerPath)
 {
     using (var stream = VersionControlServer.GetItem(fileServerPath.AsString()).DownloadFile())
         using (var memStream = new MemoryStream())
         {
             do
             {
                 var b = stream.ReadByte();
                 if (b >= 0)
                 {
                     memStream.WriteByte((byte)b);
                 }
                 else
                 {
                     return(memStream.ToArray());
                 }
             } while (true);
         }
 }
Exemplo n.º 25
0
        public IServerPath CreateSubfolder(IServerPath parentServerPath, string subfolderName)
        {
            var workspace           = GetWorkspace();
            var localParentFolder   = workspace.GetLocalItemForServerItem(parentServerPath.AsString());
            var subfolderLocalPath  = Path.Combine(localParentFolder, subfolderName);
            var subfolderServerPath = parentServerPath.Subpath(subfolderName);

            _fileSystemManager.CreateFolder(subfolderLocalPath);

            workspace.Map(subfolderServerPath.AsString(), subfolderLocalPath);
            workspace.PendAdd(subfolderLocalPath);


            workspace.CheckInWithPolicyOverride($"Create folder {subfolderName}",
                                                new string[] { subfolderLocalPath },
                                                "This folder was created automatically by the GGP Developer Tool.");

            _tfsCache.AddFolderToCache(subfolderServerPath.AsString());
            return(subfolderServerPath);
        }
 public XsdValidator(IServerPath serverPath)
 {
     this._ServerPath = serverPath;
 }
Exemplo n.º 27
0
 public ComponentDefinition(string componentID, IServerPath distributionFolder)
 {
     this.ComponentID        = componentID;
     this.DistributionFolder = distributionFolder;
 }
Exemplo n.º 28
0
 public ILocalPath GetLocalPathFromServerPath(IServerPath serverPath)
 {
     return(new LocalPath(serverPath.AsString().Replace("$/", "C:\\")
                          .Replace("/", "\\")));
 }
Exemplo n.º 29
0
 public void Branch(IServerPath targetFolder)
 {
     _tfsGateway.Branch(this.ServerPath, targetFolder.Subpath(this.Name), false);
 }
Exemplo n.º 30
0
 public TfsFile(IServerPath serverPath, ILocalPath localPath, ITfsGateway tfsGateway)
 {
     ServerPath  = serverPath;
     LocalPath   = localPath;
     _tfsGateway = tfsGateway;
 }
 public ClaimsController(IClaimsRepository claimRepository, IServerPath serverPath)
 {
     this._ClaimRepository = claimRepository;
     this._ServerPath = serverPath;
 }
Exemplo n.º 32
0
 internal bool HasCacheFor(IServerPath serverPath)
 {
     return(serverPath.AsString().StartsWith(_serverPath, StringComparison.OrdinalIgnoreCase));
 }