Ejemplo n.º 1
0
        /// <summary>
        /// Constructs SCM calculation for direct using.
        /// </summary>
        /// <param name="type">Field type.</param>
        /// <param name="fieldName">Name of the defined field.</param>
        /// <returns></returns>
        protected string scScmDirect(Fields.Type type, out string fieldName)
        {
            if (req.StepCfgData.scm == StepCfgData.SCMType.Git)
            {
                string tpl      = "#[var {0} = #[IO sout(\"git\", \"{1}\")]]";
                string tplEmpty = "#[var {0} = ]";
                switch (type)
                {
                case Fields.Type.BranchName:
                {
                    fieldName = "bName";
                    string fld = String.Format(tpl, fieldName, "rev-parse --abbrev-ref HEAD");
                    string no  = String.Format(tplEmpty, fieldName);
                    return(Resource.ScriptScmGitBox.Replace("!Var!", fld).Replace("!Else!", no));
                }

                case Fields.Type.BranchRevCount:
                {
                    fieldName = "bRevCount";
                    string fld = String.Format(tpl, fieldName, "rev-list HEAD --count");
                    string no  = String.Format(tplEmpty, fieldName);
                    return(Resource.ScriptScmGitBox.Replace("!Var!", fld).Replace("!Else!", no));
                }

                case Fields.Type.BranchSha1:
                {
                    fieldName = "bSha1";
                    string fld = String.Format(tpl, fieldName, "rev-parse --short HEAD");
                    string no  = String.Format(tplEmpty, fieldName);
                    return(Resource.ScriptScmGitBox.Replace("!Var!", fld).Replace("!Else!", no));
                }

                case Fields.Type.Informational:
                {
                    string bSha1;
                    fieldName = "info";

                    string scm = scScmDirect(Fields.Type.BranchSha1, out bSha1);
                    string val = String.Format("#[var {0} = $(ver).$(Revision) [ $({1}) ]]", fieldName, bSha1);

                    return(String.Format("{0}{1}{2}", scm, LINE_BREAK, val));
                }

                case Fields.Type.InformationalFull:
                {
                    fieldName = "infoFull";

                    string scm = Resource.ScriptScmGit
                                 .Replace("!RScmData!", String.Empty)
                                 .Replace("!RScmEmpty!", "#[var bSha1 = ]#[var bName = ]#[var bRevCount = ]");

                    string val = String.Format("#[var {0} = $(ver).$(Revision) [ $(bSha1) ] /'#[var bName]':$(bRevCount)]", fieldName);

                    return(String.Format("{0}{1}{2}", scm, LINE_BREAK, val));
                }
                }
                throw new NotFoundException("The `{0}` is not found for used scm `git`.", type);
            }
            throw new NotFoundException("The `{0}` is not found for handling scm data.", req.StepCfgData.scm);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Checking of alowing field type for selected GenType.
 /// </summary>
 /// <param name="type">The type of field.</param>
 /// <param name="gtype">The type of generator.</param>
 /// <returns></returns>
 public bool isAllow(Fields.Type type, GenType gtype)
 {
     if (gtype == GenType.CppDefinitions && type == Fields.Type.Number)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Checking of alowing field type for used revision type.
 /// </summary>
 /// <param name="type">The type of field.</param>
 /// <param name="rev">The type of revision.</param>
 /// <returns></returns>
 public bool isAllow(Fields.Type type, RevNumber.Type rev)
 {
     if (rev == RevNumber.Type.Raw && type == Fields.Type.NumberWithRevString)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
 public string this[Fields.Type type]
 {
     get {
         if (map == null || !map.ContainsKey(type))
         {
             return(defaultValue);
         }
         return(map[type]);
     }
     set {
         map[type] = value; //allowing exception for null map
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        public StepRepl()
        {
            TypeList = Enum.GetValues(typeof(ReplType))
                       .Cast <ReplType>()
                       .Select(v => new KeyValuePair <ReplType, string>(v, v.ToString()))
                       .ToList();

            rtype = TypeList[0].Key;

            SourceList = Fields.List.Where(i => i.Key != Fields.Type.Number).ToList();
            source     = SourceList[SourceList.FindIndex(i => i.Key == Fields.Type.NumberString)].Key;
            SourceList.Add(new KeyValuePair <Fields.Type, string>(Fields.Type.Null, "None used"));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        public StepRepl()
        {
            TypeList = Enum.GetValues(typeof(ReplType))
                                .Cast<ReplType>()
                                .Select(v => new KeyValuePair<ReplType, string>(v, v.ToString()))
                                .ToList();

            rtype   = TypeList[0].Key;

            SourceList  = Fields.List.Where(i => i.Key != Fields.Type.Number).ToList();
            source      = SourceList[SourceList.FindIndex(i => i.Key == Fields.Type.NumberString)].Key;
            SourceList.Add(new KeyValuePair<Fields.Type, string>(Fields.Type.Null, "None used"));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Checking of alowing field type for used scm type.
 /// </summary>
 /// <param name="type">The type of field.</param>
 /// <param name="scm">The type of SCM.</param>
 /// <returns></returns>
 public bool isAllow(Fields.Type type, StepCfgData.SCMType scm)
 {
     if ((scm == StepCfgData.SCMType.None)
         &&
         (type == Fields.Type.BranchName ||
          type == Fields.Type.BranchRevCount ||
          type == Fields.Type.BranchSha1 ||
          type == Fields.Type.Informational ||
          type == Fields.Type.InformationalFull))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Constructs direct variable from version-fields.
        /// </summary>
        /// <param name="type">Type of field.</param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        protected string scVersionDirect(Fields.Type type, out string fieldName)
        {
            string tpl = "#[var {0} = {1}]";

            switch (type)
            {
            case Fields.Type.Null: {
                fieldName = String.Empty;
                return(String.Empty);
            }

            case Fields.Type.NumberString: {
                fieldName = "numString";
                return(String.Format(tpl, fieldName, "$(ver)"));
            }

            case Fields.Type.NumberWithRevString: {
                fieldName = "numRevString";
                return(String.Format(tpl, fieldName, "$(ver).$(Revision)"));
            }
            }
            throw new NotFoundException("The `{0}` is not found for single variable from version-fields.", type);
        }