示例#1
0
 private static ArgumentString PushCmd(string remote, string toBranch)
 {
     return(new GitArgumentBuilder("push")
     {
         { GitVersion.Current.PushCanAskForProgress, "--progress" },
         remote.ToPosixPath().Trim().Quote(),
         $"HEAD:{GitRefName.GetFullBranchName(toBranch)?.Replace(" ", "")}"
     });
 }
 public void GetFullBranchNameTest()
 {
     Assert.AreEqual(null, GitRefName.GetFullBranchName(null));
     Assert.AreEqual("", GitRefName.GetFullBranchName(""));
     Assert.AreEqual("", GitRefName.GetFullBranchName("    "));
     Assert.AreEqual("4e0f0fe3f6add43557913c354de02560b8faec32", GitRefName.GetFullBranchName("4e0f0fe3f6add43557913c354de02560b8faec32"));
     Assert.AreEqual("refs/heads/master", GitRefName.GetFullBranchName("master"));
     Assert.AreEqual("refs/heads/master", GitRefName.GetFullBranchName(" master "));
     Assert.AreEqual("refs/heads/master", GitRefName.GetFullBranchName("refs/heads/master"));
     Assert.AreEqual("refs/heads/release/2.48", GitRefName.GetFullBranchName("refs/heads/release/2.48"));
     Assert.AreEqual("refs/tags/my-tag", GitRefName.GetFullBranchName("refs/tags/my-tag"));
 }
示例#3
0
        private static string PushCmd(string remote, string toBranch)
        {
            var args = new ArgumentBuilder
            {
                "push",
                { GitCommandHelpers.VersionInUse.PushCanAskForProgress, "--progress" },
                remote.ToPosixPath().Trim().Quote(),
                $"HEAD:{GitRefName.GetFullBranchName(toBranch)?.Replace(" ", "")}"
            };

            return(args.ToString());
        }
        public void GetFullBranchName()
        {
            Assert.AreEqual("refs/heads/foo", GitRefName.GetFullBranchName("foo"));

            Assert.AreEqual("refs/foo", GitRefName.GetFullBranchName("refs/foo"));

            Assert.AreEqual(
                "4e0f0fe3f6add43557913c354de02560b8faec32",
                GitRefName.GetFullBranchName("4e0f0fe3f6add43557913c354de02560b8faec32"));

            Assert.AreEqual("", GitRefName.GetFullBranchName(""));
            Assert.AreEqual("", GitRefName.GetFullBranchName("    "));

            Assert.IsNull(GitRefName.GetFullBranchName(null));
        }
示例#5
0
        private static string PushCmd(string remote, string toBranch)
        {
            remote = remote.ToPosixPath();

            toBranch = GitRefName.GetFullBranchName(toBranch);

            const string fromBranch = "HEAD";

            toBranch = toBranch?.Replace(" ", "");

            var sprogressOption = "";

            if (GitCommandHelpers.VersionInUse.PushCanAskForProgress)
            {
                sprogressOption = "--progress ";
            }

            return(string.Format("push {0}\"{1}\" {2}:{3}", sprogressOption, remote.Trim(), fromBranch, toBranch));
        }