Exemplo n.º 1
0
        /// <summary>
        /// Creates Git tags from Vault labels
        /// </summary>
        /// <returns></returns>
        public bool CreateTagsFromLabels()
        {
            vaultLogin();

            // Search for all labels recursively
            string repositoryFolderPath = "$";

            long   objId = RepositoryUtil.FindVaultTreeObjectAtReposOrLocalPath(repositoryFolderPath).ID;
            string qryToken;
            long   rowsRetMain;
            long   rowsRetRecur;

            VaultLabelItemX[] labelItems;

            ServerOperations.client.ClientInstance.BeginLabelQuery(repositoryFolderPath, objId, false, false, true, true, 0,
                                                                   out rowsRetMain,
                                                                   out rowsRetRecur,
                                                                   out qryToken);

            //ServerOperations.client.ClientInstance.BeginLabelQuery(repositoryFolderPath,
            //														   objId,
            //														   true, // get recursive
            //														   true, // get inherited
            //														   true, // get file items
            //														   true, // get folder items
            //														   0,    // no limit on results
            //														   out rowsRetMain,
            //														   out rowsRetRecur,
            //out qryToken);


            ServerOperations.client.ClientInstance.GetLabelQueryItems_Recursive(qryToken,
                                                                                0,
                                                                                (int)rowsRetRecur,
                                                                                out labelItems);

            if (labelItems == null)
            {
                labelItems = new VaultLabelItemX[0];
            }
            try
            {
                int ticks = 0;

                foreach (VaultLabelItemX currItem in labelItems)
                {
                    Console.WriteLine($"Processing label {currItem.LabelID} for version {currItem.Version} with comemnt {currItem.Comment}");

                    ///TODO: not sure how to handle this across multiple branch folders. adjusting it just so it compiles and I'll address it later
                    var gitCommitId = string.Empty; //GetMapping(currItem.Version.ToString());

                    if (!(gitCommitId?.Length > 0))
                    {
                        continue;
                    }

                    var gitLabelName = Regex.Replace(currItem.Label, "[\\W]", "_");
                    ticks += gitAddTag($"{currItem.Version}_{gitLabelName}", gitCommitId, currItem.Comment);
                }

                //add ticks for git tags
                Progress?.Invoke(ProgressSpecialVersionTags, 0L, ticks);
            }
            finally
            {
                //complete
                ServerOperations.client.ClientInstance.EndLabelQuery(qryToken);
                vaultLogout();
                gitFinalize();
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates Git tags from Vault labels
        /// </summary>
        /// <returns></returns>
        public bool CreateTagsFromLabels()
        {
            vaultLogin();

            // Search for all labels recursively
            string repositoryFolderPath = "$";

            long   objId = RepositoryUtil.FindVaultTreeObjectAtReposOrLocalPath(repositoryFolderPath).ID;
            string qryToken;
            long   rowsRetMain;
            long   rowsRetRecur;

            VaultLabelItemX[] labelItems;

            ServerOperations.client.ClientInstance.BeginLabelQuery(repositoryFolderPath,
                                                                   objId,
                                                                   true,     // get recursive
                                                                   true,     // get inherited
                                                                   true,     // get file items
                                                                   true,     // get folder items
                                                                   0,        // no limit on results
                                                                   out rowsRetMain,
                                                                   out rowsRetRecur,
                                                                   out qryToken);


            ServerOperations.client.ClientInstance.GetLabelQueryItems_Recursive(qryToken,
                                                                                0,
                                                                                (int)rowsRetRecur,
                                                                                out labelItems);
            try
            {
                int ticks = 0;

                foreach (VaultLabelItemX currItem in labelItems)
                {
                    if (!_txidMappings.ContainsKey(currItem.TxID))
                    {
                        continue;
                    }

                    string gitCommitId = _txidMappings.Where(s => s.Key.Equals(currItem.TxID)).First().Value;

                    if (gitCommitId != null && gitCommitId.Length > 0)
                    {
                        string gitLabelName = Regex.Replace(currItem.Label, "[\\W]", "_");
                        ticks += gitAddTag(currItem.TxID + "_" + gitLabelName, gitCommitId, currItem.Comment);
                    }
                }

                //add ticks for git tags
                if (null != Progress)
                {
                    Progress(ProgressSpecialVersionTags, ticks);
                }
            }
            finally
            {
                //complete
                ServerOperations.client.ClientInstance.EndLabelQuery(qryToken);
                vaultLogout();
                gitFinalize();
            }
            return(true);
        }
Exemplo n.º 3
0
 public VaultClientTreeObject FindVaultTreeObjectAtReposOrLocalPath(string testPath) => RepositoryUtil.FindVaultTreeObjectAtReposOrLocalPath(testPath);