コード例 #1
0
        public GitTfsRemote(RemoteInfo info, IGitRepository repository, RemoteOptions remoteOptions, Globals globals,
                            ITfsHelper tfsHelper, ConfigProperties properties)
        {
            _remoteOptions = remoteOptions;
            _globals       = globals;
            _properties    = properties;
            Tfs            = tfsHelper;
            Repository     = repository;

            RemoteInfo                  = info;
            Id                          = info.Id;
            TfsUrl                      = info.Url;
            TfsRepositoryPath           = info.Repository;
            TfsUsername                 = info.Username;
            TfsPassword                 = info.Password;
            Aliases                     = (info.Aliases ?? Enumerable.Empty <string>()).ToArray();
            IgnoreRegexExpression       = info.IgnoreRegex;
            IgnoreExceptRegexExpression = info.IgnoreExceptRegex;

            Autotag = info.Autotag;

            IsSubtree = CheckSubtree();
        }
コード例 #2
0
 public IGitTfsRemote InitBranch(RemoteOptions remoteOptions, string tfsRepositoryPath, int shaRootChangesetId, bool fetchParentBranch, string gitBranchNameExpected = null, IRenameResult renameResult = null)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
        private IGitTfsRemote InitTfsBranch(RemoteOptions remoteOptions, string tfsRepositoryPath, long rootChangesetId = -1, bool fetchParentBranch = false, string gitBranchNameExpected = null, IRenameResult renameResult = null)
        {
            Trace.WriteLine("Begin process of creating branch for remote :" + tfsRepositoryPath);
            // TFS string representations of repository paths do not end in trailing slashes
            tfsRepositoryPath = (tfsRepositoryPath ?? string.Empty).TrimEnd('/');

            string gitBranchName = ExtractGitBranchNameFromTfsRepositoryPath(
                string.IsNullOrWhiteSpace(gitBranchNameExpected) ? tfsRepositoryPath : gitBranchNameExpected);

            if (string.IsNullOrWhiteSpace(gitBranchName))
            {
                throw new GitTfsException("error: The Git branch name '" + gitBranchName + "' is not valid...\n");
            }
            Trace.WriteLine("Git local branch will be :" + gitBranchName);

            string sha1RootCommit = null;

            if (rootChangesetId != -1)
            {
                sha1RootCommit = Repository.FindCommitHashByChangesetId(rootChangesetId);
                if (fetchParentBranch && string.IsNullOrWhiteSpace(sha1RootCommit))
                {
                    sha1RootCommit = FindRootRemoteAndFetch((int)rootChangesetId, renameResult);
                }
                if (string.IsNullOrWhiteSpace(sha1RootCommit))
                {
                    return(null);
                }

                Trace.WriteLine("Found commit " + sha1RootCommit + " for changeset :" + rootChangesetId);
            }

            IGitTfsRemote tfsRemote;

            if (Repository.HasRemote(gitBranchName))
            {
                Trace.WriteLine("Remote already exist");
                tfsRemote = Repository.ReadTfsRemote(gitBranchName);
                if (tfsRemote.TfsUrl != TfsUrl)
                {
                    Trace.WriteLine("warning: Url is different");
                }
                if (tfsRemote.TfsRepositoryPath != tfsRepositoryPath)
                {
                    Trace.WriteLine("warning: TFS repository path is different");
                }
            }
            else
            {
                Trace.WriteLine("Try creating remote...");
                tfsRemote = Repository.CreateTfsRemote(new RemoteInfo
                {
                    Id            = gitBranchName,
                    Url           = TfsUrl,
                    Repository    = tfsRepositoryPath,
                    RemoteOptions = remoteOptions
                }, string.Empty);
            }
            if (sha1RootCommit != null && !Repository.HasRef(tfsRemote.RemoteRef))
            {
                if (!Repository.CreateBranch(tfsRemote.RemoteRef, sha1RootCommit))
                {
                    throw new GitTfsException("error: Fail to create remote branch ref file!");
                }
            }
            Trace.WriteLine("Remote created!");
            return(tfsRemote);
        }
コード例 #4
0
 public IGitTfsRemote InitBranch(RemoteOptions remoteOptions, string tfsRepositoryPath, long rootChangesetId, bool fetchParentBranch, string gitBranchNameExpected = null, IRenameResult renameResult = null)
 {
     return(InitTfsBranch(remoteOptions, tfsRepositoryPath, rootChangesetId, fetchParentBranch, gitBranchNameExpected, renameResult));
 }
コード例 #5
0
ファイル: GitRepository.cs プロジェクト: johnedmonds/git-tfs
 public void CreateTfsRemote(string remoteId, TfsChangesetInfo tfsHead, RemoteOptions remoteOptions)
 {
     CreateTfsRemote(remoteId, tfsHead.Remote.TfsUrl, tfsHead.Remote.TfsRepositoryPath, remoteOptions);
     ReadTfsRemote(remoteId).UpdateRef(tfsHead.GitCommit, tfsHead.ChangesetId);
 }
コード例 #6
0
ファイル: GitRepository.cs プロジェクト: johnedmonds/git-tfs
        public void CreateTfsRemote(string remoteId, string tfsUrl, string tfsRepositoryPath, RemoteOptions remoteOptions)
        {
            if (HasRemote(remoteId))
            {
                throw new GitTfsException("A remote with id \"" + remoteId + "\" already exists.");
            }

            if (remoteOptions != null)
            {
                if (remoteOptions.NoMetaData)
                {
                    SetTfsConfig(remoteId, "no-meta-data", 1);
                }
                if (remoteOptions.IgnoreRegex != null)
                {
                    SetTfsConfig(remoteId, "ignore-paths", remoteOptions.IgnoreRegex);
                }
                if (!string.IsNullOrEmpty(remoteOptions.Username))
                {
                    SetTfsConfig(remoteId, "username", remoteOptions.Username);
                }
                if (!string.IsNullOrEmpty(remoteOptions.Password))
                {
                    SetTfsConfig(remoteId, "password", remoteOptions.Password);
                }
            }

            SetTfsConfig(remoteId, "url", tfsUrl);
            SetTfsConfig(remoteId, "repository", tfsRepositoryPath);
            SetTfsConfig(remoteId, "fetch", "refs/remotes/" + remoteId + "/master");

            Directory.CreateDirectory(Path.Combine(GitDir, "tfs"));
            _cachedRemotes = null;
        }
コード例 #7
0
 public Bootstrapper(Globals globals, TextWriter stdout, RemoteOptions remoteOptions)
 {
     _globals       = globals;
     _stdout        = stdout;
     _remoteOptions = remoteOptions;
 }
コード例 #8
0
        public string ToJSon()
        {
            // for compatibility
            if (String.IsNullOrEmpty(RemoteOptions.URL))
            {
                RemoteOptions.URL = URL;
            }
            // TODO: clean up the string before serialized
            StringBuilder json = new StringBuilder();

            json.AppendFormat(
                "{{\"id\": \"{0}\", \"title\": \"{1}\", \"beforeOpen\": {2}, \"afterOpen\": {3}, \"beforeClose\": {4}, \"afterClose\": {5}, \"reloadId\": \"{6}\", \"reloadUrl\": {7}, \"remoteOptions\": {8}, \"isPopup\": {9} ",
                ID, Title, BeforeOpen, AfterOpen, BeforeClose, AfterClose, ReloadID, Json.Encode(ReloadURL), RemoteOptions.ToJSON(), Json.Encode(IsPopup)
                );

            if (BindEvents != null && BindEvents.Count > 0)
            {
                json.Append(",");
                json.Append(Json.Encode("bindEvents"));
                json.Append(":{");
                foreach (var item in BindEvents)
                {
                    json.Append(Json.Encode(item.Key));
                    json.Append(":");
                    json.Append(item.Value);
                    json.Append(",");
                }
                json.Remove(json.Length - 1, 1);
                json.Append("}");
            }
            if (Width != Unit.Empty)
            {
                json.Append(",");
                json.Append(Json.Encode("width"));
                json.Append(":");
                json.Append(Json.Encode(Width.ToString()));
            }
            if (Height != Unit.Empty)
            {
                json.Append(",");
                json.Append(Json.Encode("height"));
                json.Append(":");
                json.Append(Json.Encode(Height.ToString()));
            }

            json.Append("}");
            return(json.ToString());
        }
コード例 #9
0
ファイル: Bootstrapper.cs プロジェクト: zidanfei/git-tfs
 public Bootstrapper(Globals globals, RemoteOptions remoteOptions)
 {
     _globals       = globals;
     _remoteOptions = remoteOptions;
 }
コード例 #10
0
 /// <summary>
 /// Class XtrmAddons Net Application Serializable Options Constructor.
 /// </summary>
 public Options()
 {
     Data    = new DataOptions();
     Storage = new StorageOptions();
     Remote  = new RemoteOptions();
 }
コード例 #11
0
 public RemoteClientMock(RemoteOptions options)
 {
     this.Options = options;
 }