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); }
public void SetSetting(GitFlowSetting setting, string settingValue) { Settings[setting] = settingValue; }
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)); }
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; }
public string GetSetting(GitFlowSetting setting) { return(Settings.ContainsKey(setting) ? Settings[setting] : null); }