Skip to content

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

Description

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];
  }

}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions