/**
 * Copyright 2013 markiewb
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package de.markiewb.netbeans.plugin.git.openinexternalviewer.strategies;

import de.markiewb.netbeans.plugin.git.openinexternalviewer.RepoStrategy;
import java.text.MessageFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.openide.util.lookup.ServiceProvider;

/**
 * https://github.com/markiewb/nb-git-branch-in-statusbar.git
 * https://github.com/markiewb/nb-git-branch-in-statusbar/commits/master
 *
 * @author markiewb
 */
@ServiceProvider(service = RepoStrategy.class)
public final class GitHubStrategyImpl implements RepoStrategy {

    private final Pattern p = Pattern.compile("(?<protocol>http|https)://(?<username>.+?@)?(?<server>github.com)/(?<repo>.+)\\.git");

    @Override
    public String getUrl(String remote, String branchName, String branchRevId) {
        String url = null;
        if (this.supports(remote)) {
            Matcher matcher = p.matcher(remote);
            matcher.find();
            String protocol = matcher.group("protocol");
            String username = matcher.group("username");
            String server = matcher.group("server");
            String repo = matcher.group("repo");
            url = MessageFormat.format("{0}://{1}/{2}/commits/{3}", protocol, server, repo, branchName);
        }
        return url;
    }

    @Override
    public boolean supports(String remote) {
        return p.matcher(remote).matches();
    }

    @Override
    public String getLabel() {
        return "GitHub";
    }

}

@@ -1040,16 +1040,75 @@
 master%0D%0A
+ * git@github.com:markiewb/nb-git-branch-in-statusbar.git%0D%0A
  *%0D%0A * @
@@ -1271,16 +1271,20 @@
 attern p
+Http
  = Patte
@@ -1382,16 +1382,127 @@
 .git%22);%0D
+%0A    private final Pattern pGit = Pattern.compile(%22(?%3Cusername%3Egit)@(?%3Cserver%3Egithub.com):(?%3Crepo%3E.+)%5C%5C.git%22);%0D
 %0A%0D%0A    @
@@ -1655,24 +1655,82 @@
 remote)) %7B%0D%0A
+            Pattern p = this.getMatchingPattern(remote);%0D%0A
             
@@ -1830,34 +1830,238 @@
 l = 
-matcher.group(%22protocol%22);
+%22https%22;   %0D%0A            try %7B%0D%0A                String protocol = matcher.group(%22protocol%22);%0D%0A            %7D%0D%0A            catch (IndexOutOfBoundsException e) %7B%0D%0A                // Do nothing, but use default %22https%22.%0D%0A            %7D
 %0D%0A  
@@ -2443,17 +2443,56 @@
  return 
-p
+(pHttp.matcher(remote).matches() %7C%7C pGit
 .matcher
@@ -2509,16 +2509,17 @@
 atches()
+)
 ;%0D%0A    %7D
@@ -2604,11 +2604,276 @@
    %7D%0D%0A%0D%0A
+    protected Pattern getMatchingPattern(String remote) %7B%0D%0A        if (pHttp.matcher(remote).matches()) %7B%0D%0A            return pHttp;%0D%0A        %7D%0D%0A        else if (pGit.matcher(remote).matches()) %7B%0D%0A            return pGit;%0D%0A        %7D%0D%0A        return null;%0D%0A    %7D%0D%0A%0D%0A
 %7D%0D%0A

Add code to support Git URLs.