コード例 #1
0
ファイル: RemoteInfo.cs プロジェクト: srannu/gitextensions
            PullConfig(RemoteInfo remote, string line, IEnumerable <string> proceedingLines, bool isRebase)
            {
                Remote = remote;
                line   = line.Trim();
                int gapStart = line.IndexOf(" ");

                LocalBranch = line.Substring(0, gapStart);

                if (isRebase)
                {// {local} rebases onto remote {remoteBranch}
                    RemoteBranches = new string[] { GetRemoteBranch(line, RebasesOntoRemote) };
                    Config         = MergeAction.Rebase;
                }
                else
                {
                    // "localBranch merges with remote remoteBranch"
                    //                 and with remote remoteBranch
                    //                 and with remote remoteBranch
                    //             ...
                    const string mergeMarker = "with remote";
                    var          remotes     = new List <string> {
                        GetRemoteBranch(line, mergeMarker)
                    };

                    remotes.AddRange(from branch in proceedingLines
                                     select GetRemoteBranch(branch, mergeMarker));
                    RemoteBranches = remotes;
                    Config         = MergeAction.Merge;
                }
            }
コード例 #2
0
ファイル: RemoteInfo.cs プロジェクト: srannu/gitextensions
            //  Remote branches:
            //    LibGit2Sharp     tracked
            //    LibGit2Sharp     new (next fetch will store in remotes/{remote})"
            //    LibGit2Sharp     stale (use 'git remote prune' to remove)"

            internal RemoteTrackingBranch(string line, RemoteInfo remote)
            {
                int gapStart = line.IndexOf(" ");

                Name = line.Substring(0, gapStart);// branch name ends right before first space

                string status = line.Substring(gapStart).Trim().ToLower();

                foreach (var state in ValidStates)
                {
                    if (status.StartsWith(state.Key))
                    {
                        Status = state.Value;
                        if (Status == State.Stale)
                        {
                            // refs/remotes/berger/left-panel/remotes     stale (use 'git remote prune' to remove)
                            // release/2.32                               tracked
                            string staleName = string.Format("{0}{1}/", GitRef.RefsRemotesPrefix, remote.Name);
                            if (Name.StartsWith(staleName))
                            {// stale remote branch starts with "refs/remotes/{0}/"
                                Name = Name.Substring(staleName.Length);
                            }
                        }
                        break;
                    }
                }

                InternalPullConfigs = new List <PullConfig>();
                Remote   = remote;
                FullPath = string.Format(
                    "{0}{1}{2}",
                    remote.Name,
                    GitModule.RefSep,
                    Name);
            }
コード例 #3
0
ファイル: RemoteInfo.cs プロジェクト: srannu/gitextensions
            public RemoteBranch(RemoteInfo remote, string remoteBranchLine, string headBranchName)
            {
                Remote = remote;
                // $ git ls-remote --heads {remote}
                // {SHA-1}   refs/heads/{branch}

                Sha1 = remoteBranchLine.Substring(0, Sha1Length);
                var temp = remoteBranchLine.Substring(Sha1Length).Trim();// remove SHA-1, then trim

                FullRefName = temp;
                Name        = FullRefName.Substring(GitRef.RefsHeadsPrefix.Length);// remove "refs/heads/"

                IsHead = Equals(Name, headBranchName);
                if (IsHead)
                {
                    remote.HeadBranch = this;
                }
            }
コード例 #4
0
ファイル: GitRemote.cs プロジェクト: srannu/gitextensions
        /// <summary>Creates a 'git remote' command to track/un-track specified branches.</summary>
        /// <param name="remote">Remote whose branches to set.</param>
        /// <param name="option">Indicates the add/remove/reset action to perform.</param>
        /// <param name="trackingBranches">Branches to track/un-track.</param>
        public GitRemote(RemoteInfo remote, SetBranches option, params RemoteInfo.RemoteTrackingBranch[] trackingBranches)
        {                     // 'git remote set-branches [--add] <name> <branch> <branch> ...'
            string add = (option == SetBranches.Append)
                    ? "--add" // add to tracked branches
                    : "";     // reset then track/untrack branches

            IEnumerable <RemoteInfo.RemoteTrackingBranch> cmdBranches;

            if (option == SetBranches.UnTrack)
            {// un-track
                var keepers = new HashSet <RemoteInfo.RemoteTrackingBranch>(remote.RemoteTrackingBranches);
                keepers.ExceptWith(trackingBranches);
                cmdBranches = keepers;
            }
            else
            {
                cmdBranches = trackingBranches.AsEnumerable();
            }

            string branchesString = string.Join(" ", cmdBranches);

            // 'git remote set-branches [--add] <name> <branch> <branch> ...'
            cmd = string.Format("remote set-branches {0} {1} {2}", remote.Name, add, branchesString);
        }
コード例 #5
0
ファイル: GitRemote.cs プロジェクト: akrisiun/gitextensions
        /// <summary>Creates a 'git remote' command to track/un-track specified branches.</summary>
        /// <param name="remote">Remote whose branches to set.</param>
        /// <param name="option">Indicates the add/remove/reset action to perform.</param>
        /// <param name="trackingBranches">Branches to track/un-track.</param>
        public GitRemote(RemoteInfo remote, SetBranches option, params RemoteInfo.RemoteTrackingBranch[] trackingBranches)
        {
            // 'git remote set-branches [--add] <name> <branch> <branch> ...'
            string add = (option == SetBranches.Append)
                    ? "--add" // add to tracked branches
                    : "";// reset then track/untrack branches

            IEnumerable<RemoteInfo.RemoteTrackingBranch> cmdBranches;
            if (option == SetBranches.UnTrack)
            {// un-track
                var keepers = new HashSet<RemoteInfo.RemoteTrackingBranch>(remote.RemoteTrackingBranches);
                keepers.ExceptWith(trackingBranches);
                cmdBranches = keepers;

            }
            else
            {
                cmdBranches = trackingBranches.AsEnumerable();
            }

            string branchesString = string.Join(" ", cmdBranches);
            // 'git remote set-branches [--add] <name> <branch> <branch> ...'
            cmd = string.Format("remote set-branches {0} {1} {2}", remote.Name, add, branchesString);
        }
コード例 #6
0
ファイル: RemoteInfo.cs プロジェクト: akrisiun/gitextensions
 /// <summary>Creates a new <see cref="PullConfig"/> which rebases onto a remote.</summary>
 internal PullConfig(RemoteInfo remote, string line)
     : this(remote, line, null, true)
 {
 }
コード例 #7
0
ファイル: GitRemote.cs プロジェクト: srannu/gitextensions
 /// <summary>Reset the current remote-tracking branches and only track the specified branches.</summary>
 public static GitRemote TrackOnly(RemoteInfo remote, params RemoteInfo.RemoteTrackingBranch[] trackingBranches)
 {
     return(new GitRemote(remote, SetBranches.Reset, trackingBranches));
 }
コード例 #8
0
ファイル: GitRemote.cs プロジェクト: srannu/gitextensions
 /// <summary>Un-track the specified remote-tracking branches.</summary>
 public static GitRemote UnTrack(RemoteInfo remote, params RemoteInfo.RemoteTrackingBranch[] trackingBranches)
 {
     return(new GitRemote(remote, SetBranches.UnTrack, trackingBranches));
 }
コード例 #9
0
ファイル: GitModule.cs プロジェクト: Yasami/gitextensions
 /// <summary>Indicates whether a remote branch is lacking commits that are in a local branch/revision.</summary>
 /// <param name="aheadRevision">Local branch/revision.</param>
 /// <param name="remoteTrackingBranch">Remote branch to check if it's behind.</param>
 public bool IsRemoteBranchBehind(RemoteInfo.RemoteTrackingBranch remoteTrackingBranch, string aheadRevision)
 {
     return IsBranchBehind(remoteTrackingBranch.FullPath, aheadRevision);
 }
コード例 #10
0
ファイル: RemoteInfo.cs プロジェクト: akrisiun/gitextensions
            public RemoteBranch(RemoteInfo remote, string remoteBranchLine, string headBranchName)
            {
                Remote = remote;
                // $ git ls-remote --heads {remote}
                // {SHA-1}   refs/heads/{branch}

                Sha1 = remoteBranchLine.Substring(0, Sha1Length);
                var temp = remoteBranchLine.Substring(Sha1Length).Trim();// remove SHA-1, then trim
                FullRefName = temp;
                Name = FullRefName.Substring(GitRef.RefsHeadsPrefix.Length);// remove "refs/heads/"

                IsHead = Equals(Name, headBranchName);
                if (IsHead)
                {
                    remote.HeadBranch = this;
                }
            }
コード例 #11
0
ファイル: GitModule.cs プロジェクト: Yasami/gitextensions
 /// <summary>Gets the number of commits which appear in a remote branch that are NOT in another branch/revision.
 /// <remarks>Indicates how many commits the local branch is behind the remote branch; possibly for pulling.</remarks></summary>
 /// <param name="behindRevision">Revision/branch to check how many commits it's behind.</param>
 /// <param name="remoteTrackingBranch">Remote branch.</param>
 public int GetCommitDiffCount(string behindRevision, RemoteInfo.RemoteTrackingBranch remoteTrackingBranch)
 {
     return GetCommitDiffCount(behindRevision, remoteTrackingBranch.FullPath);
 }
コード例 #12
0
ファイル: GitRemote.cs プロジェクト: akrisiun/gitextensions
 /// <summary>Un-track the specified remote-tracking branches.</summary>
 public static GitRemote UnTrack(RemoteInfo remote, params RemoteInfo.RemoteTrackingBranch[] trackingBranches)
 {
     return new GitRemote(remote, SetBranches.UnTrack, trackingBranches);
 }
コード例 #13
0
ファイル: GitRemote.cs プロジェクト: akrisiun/gitextensions
 /// <summary>Reset the current remote-tracking branches and only track the specified branches.</summary>
 public static GitRemote TrackOnly(RemoteInfo remote, params RemoteInfo.RemoteTrackingBranch[] trackingBranches)
 {
     return new GitRemote(remote, SetBranches.Reset, trackingBranches);
 }
コード例 #14
0
ファイル: RemoteInfo.cs プロジェクト: srannu/gitextensions
 /// <summary>Creates a new <see cref="PullConfig"/> which merges onto remote(s).</summary>
 internal PullConfig(RemoteInfo remote, string firstLine, IEnumerable <string> proceedingLines)
     : this(remote, firstLine, proceedingLines, false)
 {
 }
コード例 #15
0
ファイル: RemoteInfo.cs プロジェクト: srannu/gitextensions
 /// <summary>Creates a new <see cref="PullConfig"/> which rebases onto a remote.</summary>
 internal PullConfig(RemoteInfo remote, string line)
     : this(remote, line, null, true)
 {
 }
コード例 #16
0
ファイル: RemoteInfo.cs プロジェクト: akrisiun/gitextensions
 /// <summary>Creates a new <see cref="PullConfig"/> which merges onto remote(s).</summary>
 internal PullConfig(RemoteInfo remote, string firstLine, IEnumerable<string> proceedingLines)
     : this(remote, firstLine, proceedingLines, false)
 {
 }
コード例 #17
0
ファイル: RemoteInfo.cs プロジェクト: akrisiun/gitextensions
            PullConfig(RemoteInfo remote, string line, IEnumerable<string> proceedingLines, bool isRebase)
            {
                Remote = remote;
                line = line.Trim();
                int gapStart = line.IndexOf(" ");

                LocalBranch = line.Substring(0, gapStart);

                if (isRebase)
                {// {local} rebases onto remote {remoteBranch}
                    RemoteBranches = new string[] { GetRemoteBranch(line, RebasesOntoRemote) };
                    Config = MergeAction.Rebase;
                }
                else
                {
                    // "localBranch merges with remote remoteBranch"
                    //                 and with remote remoteBranch
                    //                 and with remote remoteBranch
                    //             ...
                    const string mergeMarker = "with remote";
                    var remotes = new List<string> { GetRemoteBranch(line, mergeMarker) };

                    remotes.AddRange(from branch in proceedingLines
                                     select GetRemoteBranch(branch, mergeMarker));
                    RemoteBranches = remotes;
                    Config = MergeAction.Merge;
                }
            }
コード例 #18
0
ファイル: GitModule.cs プロジェクト: Yasami/gitextensions
 /// <summary>Gets the number of commits which appear in a local branch/revision that are NOT in a remote branch.
 /// <remarks>Indicates how many commits the local branch is ahead of the remote branch.</remarks></summary>
 /// <param name="remoteTrackingBranch">Remote branch to check the number of commits it's behind.</param>
 /// <param name="aheadRevision">Local revision/branch.</param>
 public int GetCommitDiffCount(RemoteInfo.RemoteTrackingBranch remoteTrackingBranch, string aheadRevision)
 {
     return GetCommitDiffCount(remoteTrackingBranch.FullPath, aheadRevision);
 }
コード例 #19
0
ファイル: RemoteInfo.cs プロジェクト: akrisiun/gitextensions
                .ToDictionary(state => state.ToString().ToLower()); // e.g. "tracked" -> Tracked

            #endregion Fields

            #region Constructors

            //  Remote branches:
            //    LibGit2Sharp     tracked
            //    LibGit2Sharp     new (next fetch will store in remotes/{remote})"
            //    LibGit2Sharp     stale (use 'git remote prune' to remove)"
            internal RemoteTrackingBranch(string line, RemoteInfo remote)
            {
                int gapStart = line.IndexOf(" ");
                Name = line.Substring(0, gapStart);// branch name ends right before first space

                string status = line.Substring(gapStart).Trim().ToLower();
                foreach (var state in ValidStates)
                {
                    if (status.StartsWith(state.Key))
                    {
                        Status = state.Value;
                        if (Status == State.Stale)
                        {
                            // refs/remotes/berger/left-panel/remotes     stale (use 'git remote prune' to remove)
                            // release/2.32                               tracked
                            string staleName = string.Format("{0}{1}/", GitRef.RefsRemotesPrefix, remote.Name);
                            if (Name.StartsWith(staleName))
                            {// stale remote branch starts with "refs/remotes/{0}/"
                                Name = Name.Substring(staleName.Length);
                            }
                        }
                        break;
                    }
                }

                InternalPullConfigs = new List<PullConfig>();
                Remote = remote;
                FullPath = string.Format(
                    "{0}{1}{2}",
                    remote.Name,
                    GitModule.RefSep,
                    Name);
            }
コード例 #20
0
ファイル: GitModule.cs プロジェクト: Yasami/gitextensions
 /// <summary>Indicates whether a local branch/revision is behind a remote branch; possibly for pulling.</summary>
 /// <param name="behindRevision">Local branch/revision to check if it's behind.</param>
 /// <param name="remoteTrackingBranch">Remote branch.</param>
 public bool IsBranchBehind(string behindRevision, RemoteInfo.RemoteTrackingBranch remoteTrackingBranch)
 {
     return IsBranchBehind(behindRevision, remoteTrackingBranch.FullPath);
 }