Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for repositories using ssh in github-deploy #753

Closed
ghost opened this issue Jul 4, 2016 · 1 comment
Closed

Add support for repositories using ssh in github-deploy #753

ghost opened this issue Jul 4, 2016 · 1 comment
Assignees

Comments

@ghost
Copy link

ghost commented Jul 4, 2016

Note: for support questions, please use one of these channels: Chat: AngularClass.slack or Twitter: @AngularClass

  • I'm submitting a ...
    [ ] bug report
    [X ] feature request
    [ ] question about the decisions made in the repository
  • Do you want to request a feature or report a bug?
    Request a feature. Add support to extract repository name when using ssh in connection with github-deploy feature.
  • What is the current behavior?
    getRepoName(remoteName) only extracts the repository name if the remote is https. Otherwise, it throws an error.
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
    https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).
  • What is the expected behavior?
  • What is the motivation / use case for changing the behavior?
    Catch both https and ssh use cases for gh-pages.
  • Please tell us about your environment:
  • Angular version: 2.0.0-r.c.4
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

I simply added a nested if function to catch my ssh case:

const HTTPS_REPO_NAME_RE = /Push  URL: https:\/\/github\.com\/.*\/(.*)\.git/;
const SSH_REPO_NAME_RE = /Push\s*URL:\s*git@github\.com:.*\/(.*)\.git/;

function getRepoName(remoteName) {
  remoteName = remoteName || 'origin';

  var stdout_https = execSync('git remote show ' + remoteName),
      match_https = HTTPS_REPO_NAME_RE.exec(stdout_https);

  var stdout_ssh = execSync('git remote show ' + remoteName),
      match_ssh = SSH_REPO_NAME_RE.exec(stdout_ssh);

  if (!match_https) {
     if (!match_ssh) {
        throw new Error('Could not find a repository on remote ' + remoteName);
     } else {
       return match_ssh[1];
    }} else {
      return match_https[1];
  }

}
@shlomiassaf shlomiassaf self-assigned this Jul 4, 2016
@shlomiassaf
Copy link
Contributor

shlomiassaf commented Jul 4, 2016

@thatn3wguy If you post a PR I will merge it.

If not I'll get to it sometime soon.

If you do, try having 1 regex instead of 2

awcodify pushed a commit to awcodify/d3-angular-4 that referenced this issue Aug 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant