public void ParseBitbucket(string url) { var x = RevisionSource.Parse(url); Assert.Equal("bitbucket", x.Provider.Name); Assert.Equal("example", x.AccountName); Assert.Equal("repo", x.RepositoryName); }
public void ParseUrl(string url) { var x = RevisionSource.Parse(url); Assert.Equal("github", x.Provider.Name); Assert.Equal("carbon", x.AccountName); Assert.Equal("cropper", x.RepositoryName); Assert.Equal("branch", x.Revision.Value.Name); }
public void ParseTests() { var x = RevisionSource.Parse("npm/npm"); Assert.Equal("github", x.Provider.Name); Assert.Equal("npm", x.AccountName); Assert.Equal("npm", x.RepositoryName); Assert.Equal("npm/npm", x.ToString()); }
public void ParseTests2() { var x = RevisionSource.Parse("carbon/cropper#master"); Assert.Equal("github", x.Provider.Name); Assert.Equal("carbon", x.AccountName); Assert.Equal("cropper", x.RepositoryName); Assert.Equal("master", x.Revision.Value.Name); Assert.Equal("carbon/cropper#master", x.ToString()); }
public RepositoryClient(Uri url, OAuth2Token accessToken) { #region Preconditions if (url == null) { throw new ArgumentNullException(nameof(url)); } #endregion // https://github.com/{orgName}/{repoName}.git var info = RevisionSource.Parse(url); AccountName = info.AccountName; RepositoryName = info.RepositoryName; client = new GitHubClient(accessToken); }
public async Task <IRepositoryClient> GetAsync(IRepository repository) { Ensure.NotNull(repository, nameof(repository)); if (repository.EncryptedAccessToken == null) { throw new ArgumentException("Missing accessToken", nameof(repository)); } var origin = RevisionSource.Parse(repository.Origin); var accessTokenBytes = await dataDecryptor.DecryptAsync(repository.EncryptedAccessToken); var accessToken = new OAuth2Token(Encoding.UTF8.GetString(accessTokenBytes)); var client = new RepositoryClient( accountName: origin.AccountName, repositoryName: origin.RepositoryName, accessToken: accessToken ); return(client); }
// https://bitbucket.org/{accontName}/{repositoryName}.git public BitbucketRepository(Uri url, NetworkCredential credential) { #region Preconditions if (url == null) { throw new ArgumentNullException(nameof(url)); } if (credential == null) { throw new ArgumentNullException(nameof(credential)); } #endregion var repo = RevisionSource.Parse(url); AccountName = repo.AccountName; RepositoryName = repo.RepositoryName; client = new BitbucketClient(credential); }