internal static bool IsOnSpecifiedBranch(this Flow gitFlow, GitFlowSetting setting)
        {
            var repo = gitFlow.Repository;

            if (!gitFlow.IsInitialized())
            {
                return(false);
            }
            var featurePrefix = repo.Config.Get <string>(GetConfigKey(setting));

            return(featurePrefix != null && repo.Head.FriendlyName.StartsWith(featurePrefix.Value));
        }
        internal static Branch StartNewBranch(this Flow gitFlow, GitFlowSetting originationBranch, GitFlowSetting branchBase, string leafname, bool shouldFetchRemote = false, bool trackRemote = false)
        {
            //TODO: Handle fetching from remote
            if (!IsOnSpecifiedBranch(gitFlow, originationBranch))
            {
                var currentBranch = gitFlow.Repository.Checkout(gitFlow.GetBranch(originationBranch));
                //TODO: Handle non-clean checkout exceptions

                // Don't know if this check really is needed
                if (currentBranch?.FriendlyName != gitFlow.GetPrefixByBranch(originationBranch))
                {
                    return(null);
                }
            }
            var newBranchName = $"{gitFlow.GetPrefixByBranch(branchBase)}{leafname}";
            var newBranch     = gitFlow.Repository.AddGetBranch(newBranchName, track: trackRemote);

            //var newBranch = gitFlow.Repository.CreateBranch($"{gitFlow.GetPrefixByBranch(branchBase)}{leafname}");
            return(gitFlow.Repository.Checkout(newBranch));
        }
 internal static string GetConfigKey(GitFlowSetting setting)
 {
     return setting.GetAttribute<GitFlowConfigAttribute>().ConfigName;
 }
 internal static Branch GetBranch(this Flow gitFlow, GitFlowSetting branch, string leafname="")
 {
     return gitFlow.Repository.Branches[gitFlow.GetPrefixByBranch(branch) + leafname];
 }
 internal static IEnumerable<BranchInfo> GetAllBranchesByPrefix(this Flow gitFlow, GitFlowSetting setting)
 {
     var prefix = gitFlow.GetPrefixByBranch(setting);
     return gitFlow.GetAllBranchesByPrefix(prefix);
 }
        internal static Branch StartNewBranch(this Flow gitFlow, GitFlowSetting originationBranch,GitFlowSetting branchBase, string leafname, bool shouldFetchRemote=false, bool trackRemote = false)
        {
            //TODO: Handle fetching from remote
            if (!IsOnSpecifiedBranch(gitFlow, originationBranch))
            {
                var currentBranch = gitFlow.Repository.Checkout(gitFlow.GetBranch(originationBranch));
                //TODO: Handle non-clean checkout exceptions

                // Don't know if this check really is needed
                if (currentBranch?.FriendlyName != gitFlow.GetPrefixByBranch(originationBranch))
                    return null;
            }
            var newBranchName = $"{gitFlow.GetPrefixByBranch(branchBase)}{leafname}";
            var newBranch = gitFlow.Repository.AddGetBranch(newBranchName,track:trackRemote);
            //var newBranch = gitFlow.Repository.CreateBranch($"{gitFlow.GetPrefixByBranch(branchBase)}{leafname}");
            return gitFlow.Repository.Checkout(newBranch);
        }
 internal static bool IsOnSpecifiedBranch(this Flow gitFlow, GitFlowSetting setting)
 {
     var repo = gitFlow.Repository;
     if (!gitFlow.IsInitialized())
         return false;
     var featurePrefix = repo.Config.Get<string>(GetConfigKey(setting));
     return featurePrefix != null && repo.Head.FriendlyName.StartsWith(featurePrefix.Value);
 }
Ejemplo n.º 8
0
 public void SetSetting(GitFlowSetting setting, string settingValue)
 {
     Settings[setting] = settingValue;
 }
Ejemplo n.º 9
0
 public string GetSetting(GitFlowSetting setting)
 {
     return Settings.ContainsKey(setting) ? Settings[setting] : null;
 }
 internal static Branch GetBranch(this Flow gitFlow, GitFlowSetting branch, string leafname = "")
 {
     return(gitFlow.Repository.Branches[gitFlow.GetPrefixByBranch(branch) + leafname]);
 }
 internal static string GetPrefixByBranch(this Flow gitFlow, GitFlowSetting branch)
 {
     return(gitFlow.Repository.Config.Get <string>(branch.GetAttribute <GitFlowConfigAttribute>().ConfigName)?.Value);
 }
 internal static string GetConfigKey(GitFlowSetting setting)
 {
     return(setting.GetAttribute <GitFlowConfigAttribute>().ConfigName);
 }
        internal static IEnumerable <BranchInfo> GetAllBranchesByPrefix(this Flow gitFlow, GitFlowSetting setting)
        {
            var prefix = gitFlow.GetPrefixByBranch(setting);

            return(gitFlow.GetAllBranchesByPrefix(prefix));
        }
 internal static string GetFullBranchName(this Flow gitFlow,GitFlowSetting branch, string leafname)
 {
     return GetFullBranchName(gitFlow.GetPrefixByBranch(branch), leafname);
 }
 internal static string GetFullBranchName(this Flow gitFlow, GitFlowSetting branch, string leafname)
 {
     return(GetFullBranchName(gitFlow.GetPrefixByBranch(branch), leafname));
 }
Ejemplo n.º 16
0
 internal static void CreateLocalTestBranch(Repository repo, string branchName, GitFlowSetting setting, GitFlowRepoSettings repoConfig)
 {
     if (!string.IsNullOrWhiteSpace(branchName))
     {
         repoConfig.SetSetting(setting, branchName);
         repo.CreateBranch(branchName);
     }
 }
 internal static string GetPrefixByBranch(this Flow gitFlow, GitFlowSetting branch)
 {
     return gitFlow.Repository.Config.Get<string>(branch.GetAttribute<GitFlowConfigAttribute>().ConfigName)?.Value;
 }
Ejemplo n.º 18
0
 public void SetSetting(GitFlowSetting setting, string settingValue)
 {
     Settings[setting] = settingValue;
 }
Ejemplo n.º 19
0
 public string GetSetting(GitFlowSetting setting)
 {
     return(Settings.ContainsKey(setting) ? Settings[setting] : null);
 }