Domanda

Riepilogo
Al momento ho uno script di build NAnt che esegue una vssget sia sul codice sorgente più recente, o un ramo specifico (utilizzando un parametro ${branch}).

Ogni volta che facciamo una produzione build / distribuzione il codice-albero che è stato costruito ha creato un ramo, (in modo da poter continuare lo sviluppo e ancora sapere che cosa codebase è in produzione, piuttosto roba standard ...)

problema
Il processo di creazione di quel ramo è ancora un manuale, eseguita da qualcuno che va in Visual Source Safe Explorer e di eseguire la procedura di ramificazione. Mi chiedevo se non v'è alcun modo in NAnt di creare un ramo VSS.

Piano di corrente
So già sull'utilizzo <exec program="ss"> e sto cercando di evitarlo, ma in assenza di soluzioni migliori, che è la più probabile percorso mi prenderò.

Qualcuno sa se c'è un obiettivo NAnt o NAntContrib per questo, o se qualcuno ha un compito script che hanno usato per fare questo in passato e potrebbero fornire il codice per questo, che sarebbe molto apprezzato.

responsabilità
che so di CVS, SVN, git e tutte le altre soluzioni di controllo del codice sorgente e di cambiare l'utensile non è un'opzione al momento

È stato utile?

Soluzione

In realtà abbiamo bisogno di questo in cui lavoro. Ho sbattuto insieme una piccola operazione chiamata 'vssbranch' (non particolarmente creativo, ma qui è il codice ... un file di build esempio e l'uscita della sua esecuzione:

codice:

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

using SourceSafeTypeLib;

using NAnt.Core;
using NAnt.Core.Attributes;

namespace NAnt.Contrib.Tasks.SourceSafe
{
    [TaskName("vssbranch")]
    public sealed class BranchTask : BaseTask
    {
        /// <summary>
        /// The label comment.
        /// </summary>
        [TaskAttribute("comment")]
        public String Comment { get; set; }

        /// <summary>
        /// Determines whether to perform the branch recursively.
        /// The default is <see langword="true"/>
        /// </summary>
        [TaskAttribute("recursive"),
        BooleanValidator()]
        public Boolean Recursive { get; set; }

        [TaskAttribute("branchname", Required = true)]
        public String BranchName { get; set; }


        protected override void ExecuteTask()
        {
            this.Open();
            try
            {
                if (VSSItemType.VSSITEM_PROJECT != (VSSItemType)this.Item.Type)
                    throw new BuildException("Only vss projects can be branched", this.Location);

                IVSSItem newShare = null;
                this.Comment = String.IsNullOrEmpty(this.Comment) ? String.Empty : this.Comment;
                if (null != this.Item.Parent)
                    newShare = this.Item.Parent.NewSubproject(this.BranchName, this.Comment);

                if (null != newShare)
                {
                    newShare.Share(this.Item as VSSItem, this.Comment,
                        (this.Recursive) ?
                            (int)VSSFlags.VSSFLAG_RECURSYES : 0);
                    foreach (IVSSItem item in newShare.get_Items(false))
                        this.BranchItem(item, this.Recursive);
                }
            }
            catch (Exception ex)
            {
                throw new BuildException(String.Format("Failed to branch '{0}' to '{1}'", this.Item.Name, this.BranchName), this.Location, ex);
            }
        }

        private void BranchItem(IVSSItem itemToBranch, Boolean recursive)
        {
            if (null == itemToBranch) return;

            if (this.Verbose)
                this.Log(Level.Info, String.Format("Branching {0} path: {1}", itemToBranch.Name, itemToBranch.Spec));

            if (VSSItemType.VSSITEM_FILE == (VSSItemType)itemToBranch.Type)
                itemToBranch.Branch(this.Comment, 0);
            else if (recursive)
            {
                foreach (IVSSItem item in itemToBranch.get_Items(false))
                    this.BranchItem(item, recursive);
            }
        }
    }
}

build:

                                                             

        <echo message="About to execute: VSS Branch" />

        <echo message="Source Safe Path: ${SourceSafeRootPath}/${CURRENT_FILE}" />

        <vssbranch
              username="my_user_name"
              password="my_password"
              recursive="true"
              comment="attempt to make a branch"
              branchname="test-branch"
              dbpath="${SourceSafeDBPath}"
              path="${SourceSafeRootPath}/${CURRENT_FILE}"
              verbose="true"
            />

    </foreach>
</target>

USCITA:

NAnt 0.85 (Costruire 0.85.2478.0; rilascio; 2006/10/14) Copyright (C) 2001-2006 Gerry Shaw http://nant.sourceforge.net

BuildFile: file: /// C: /scm/custom/src/VssBranch/bin/Debug/test.build framework di destinazione: Microsoft .NET Framework 2.0 Target (s) specificato: run

Esegui:

[loadtasks] scansione di assemblaggio "NAnt.Contrib.Tasks" per le estensioni. [Loadtasks] Scansione montaggio "VssBranch" per le estensioni.      [Eco] A proposito di eseguire: VSS Branch

....

[vssbranch] percorso Branching SecurityProto: $ / VSS / di Endur Source / C # / DailyLive / proto / test-ramo / SecurityProto

....

BUILD RIUSCITA

Totale tempo:. 12,9 secondi

Ovviamente l'uscita varierebbe, stavo tirando nelle voci in ramo da un file di testo denominato 'params.txt'. Questo effettua l'operazione per quello che è conosciuto in tutto il mondo VSS come 'Share e Branch' (Branching subito dopo Sharing) ... altri sistemi di controllo di origine non hanno bisogno di quota prima di ramificazione, eh ... questo è un altro giorno

Altri suggerimenti

I compiti VSS vivono nel progetto NAntContrib e non, attualmente non c'è compito che supporti ramificazione. Anche se, secondo il modello dei compiti VSS esistenti (add, checkout, check-in, ecc) in NAntContrib, si potrebbe afferrare la fonte ed estendere da soli. Cioè, se i supporti VSS API ramificazione.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top