コード例 #1
0
        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));
        }
コード例 #2
0
        internal static IEnumerable <BranchInfo> GetAllBranchesByPrefix(this Flow gitFlow, string prefix)
        {
            var repo = gitFlow.Repository;

            if (gitFlow.IsInitialized())
            {
                var featureBranches =
                    repo.Branches.Where(b => !b.IsRemote && b.FriendlyName.StartsWith(prefix))
                    .Select(c => new BranchInfo(c, prefix)).ToList();

                var remoteFeatureBranches =
                    repo.Branches.Where(b => b.IsRemote && b.FriendlyName.Contains(prefix) &&
                                        !repo.Branches.Any(br => !br.IsRemote && br.IsTracking && br.TrackedBranch.CanonicalName == b.CanonicalName))
                    .Select(c => new BranchInfo(c, prefix)).ToList();

                featureBranches.AddRange(remoteFeatureBranches);
                return(featureBranches);
            }
            return(new List <BranchInfo>());
        }
コード例 #3
0
        public static void Init(this Flow gitFlow, GitFlowRepoSettings settings, Signature author)
        {
            var repo = gitFlow.Repository;

            //Only init if it is not initialized
            if (gitFlow.IsInitialized())
            {
                //TODO: Does Init do anything if already initialized? Is it sufficient to just check the ConfigValues? Should it check branch existance as well?
                return;
            }

            if (gitFlow.IsEmptyRepository())
            {
                Log("New Repository Detected - Creating Master Branch");
                //TODO: Decide if Init should create necesarry branches too?
                //Create Master branch
                Signature committer = author;
                var       opts      = new CommitOptions {
                    AllowEmptyCommit = true
                };
                repo.Commit("Initial commit", author, committer, opts);
                //Now make Dev
            }

            SetupMasterBranch(repo, settings.Settings[GitFlowSetting.Master], author);
            SetupDevBranch(repo, settings.Settings[GitFlowSetting.Develop], settings.Settings[GitFlowSetting.Master],
                           author);

            //TODO.. Repo has branches

            settings.Settings
            .ToList()
            .ForEach(item =>
                     repo.Config.Set(GetConfigKey(item.Key), item.Value, settings.ConfigurationLocation)
                     );

            Log("Init Complete");
        }