Beispiel #1
0
        /// <summary>
        /// Returns all relevant github-remotes for the current working directory
        /// </summary>
        /// <returns></returns>
        public List <IHostedRemote> GetHostedRemotesForModule(IGitModule aModule)
        {
            var repoInfos = new List <IHostedRemote>();

            string[] remotes = aModule.GetRemotes(false);
            foreach (string remote in remotes)
            {
                var url = aModule.GetISetting(string.Format(SettingKeyString.RemoteUrl, remote));
                if (string.IsNullOrEmpty(url))
                {
                    continue;
                }

                var m = Regex.Match(url, @"git(?:@|://)github.com[:/]([^/]+)/([\w_\.\-]+)\.git");
                if (!m.Success)
                {
                    m = Regex.Match(url, @"https?://(?:[^@:]+)?(?::[^/@:]+)?@?github.com/([^/]+)/([\w_\.\-]+)(?:.git)?");
                }
                if (m.Success)
                {
                    var hostedRemote = new GithubHostedRemote(remote, m.Groups[1].Value, m.Groups[2].Value.Replace(".git", ""));
                    if (!repoInfos.Contains(hostedRemote))
                    {
                        repoInfos.Add(hostedRemote);
                    }
                }
            }

            return(repoInfos);
        }
Beispiel #2
0
        /// <summary>
        /// Returns all relevant github-remotes for the current working directory
        /// </summary>
        /// <returns></returns>
        public List<IHostedRemote> GetHostedRemotesForCurrentWorkingDirRepo()
        {
            var repoInfos = new List<IHostedRemote>();

            string[] remotes = GitCommands.Settings.Module.GetRemotes(false);
            foreach(string remote in remotes)
            {
                var url = GitCommands.Settings.Module.GetSetting("remote." + remote + ".url");
                if (string.IsNullOrEmpty(url))
                    continue;

                var m = Regex.Match(url, @"git(?:@|://)github.com[:/]([^/]+)/([\w_\.]+)\.git");
                if (!m.Success)
                    m = Regex.Match(url, @"https?://(?:[^@:]+)?(?::[^/@:]+)?@?github.com/([^/]+)/([\w_\.]+)(?:.git)?");
                if (m.Success)
                {
                    var hostedRemote = new GithubHostedRemote(remote, m.Groups[1].Value, m.Groups[2].Value.Replace(".git", ""));
                    if (!repoInfos.Contains(hostedRemote))
                        repoInfos.Add(hostedRemote);
                }
            }

            return repoInfos;
        }
Beispiel #3
0
        /// <summary>
        /// Returns all relevant github-remotes for the current working directory
        /// </summary>
        /// <returns></returns>
        public List<IHostedRemote> GetHostedRemotesForModule(IGitModule aModule)
        {
            var repoInfos = new List<IHostedRemote>();

            string[] remotes = aModule.GetRemotes(false);
            foreach (string remote in remotes)
            {
                var url = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                if (string.IsNullOrEmpty(url))
                    continue;

                var m = Regex.Match(url, @"git(?:@|://)github.com[:/]([^/]+)/([\w_\.\-]+)\.git");
                if (!m.Success)
                    m = Regex.Match(url, @"https?://(?:[^@:]+)?(?::[^/@:]+)?@?github.com/([^/]+)/([\w_\.\-]+)(?:.git)?");
                if (m.Success)
                {
                    var hostedRemote = new GithubHostedRemote(remote, m.Groups[1].Value, m.Groups[2].Value.Replace(".git", ""));
                    if (!repoInfos.Contains(hostedRemote))
                        repoInfos.Add(hostedRemote);
                }
            }

            return repoInfos;
        }