Skip to content

Commit 6334683

Browse files
remove call to workspaces API and directly call repositories API
(fixes #50) Call to workspaces API is not necessary if all we need is the repositories API URL. The repositories API accepts a workspace ID anyway. (Bitbucket support, Ticket BBS-134983) Note: the parameter must be the workspace ID, no matter which of the two APIs are called. There's no difference between users and teams anymore!
1 parent 2dc9d5d commit 6334683

4 files changed

Lines changed: 2 additions & 65 deletions

File tree

src/ScmBackup/Hosters/Bitbucket/BitbucketApi.cs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,11 @@ public List<HosterRepository> GetRepositoryList(ConfigSource source)
3030
request.AddBasicAuthHeader(source.AuthName, source.Password);
3131
}
3232

33-
string workspaceUrl = string.Empty;
34-
string url = string.Empty;
33+
string url = "/2.0/repositories/" + source.Name;
3534

36-
// 1. load repo url from workspace
37-
workspaceUrl = "/2.0/workspaces/" + source.Name;
38-
39-
var result = request.Execute(workspaceUrl).Result;
40-
if (result.IsSuccessStatusCode)
41-
{
42-
var apiResponse = JsonConvert.DeserializeObject<BitbucketApiWorkspaceResponse>(result.Content);
43-
if (apiResponse != null)
44-
{
45-
Dictionary<string, string> repo;
46-
if (apiResponse.links.TryGetValue("repositories", out repo))
47-
{
48-
repo.TryGetValue("href", out url);
49-
}
50-
}
51-
}
52-
else
53-
{
54-
throw new InvalidOperationException(string.Format(Resource.ApiBitbucketNoWorkspace, source.Name));
55-
}
56-
57-
if (string.IsNullOrWhiteSpace(url))
58-
{
59-
throw new InvalidOperationException(string.Format(Resource.ApiBitbucketNoRepoUrl, source.Name));
60-
}
61-
62-
// 2. load repositories
6335
while (url != null)
6436
{
65-
result = request.Execute(url).Result;
37+
var result = request.Execute(url).Result;
6638

6739
if (result.IsSuccessStatusCode)
6840
{

src/ScmBackup/Hosters/Bitbucket/BitbucketApiWorkspaceResponse.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/ScmBackup/Resource.Designer.cs

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ScmBackup/Resource.resx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,6 @@
120120
<data name="ApiAuthenticationFailed" xml:space="preserve">
121121
<value>Authentication failed for {0}</value>
122122
</data>
123-
<data name="ApiBitbucketNoRepoUrl" xml:space="preserve">
124-
<value>No repository URL found for workspace {0}</value>
125-
</data>
126-
<data name="ApiBitbucketNoWorkspace" xml:space="preserve">
127-
<value>No workspace named {0} found!</value>
128-
</data>
129123
<data name="ApiGettingRepos" xml:space="preserve">
130124
<value>Getting repositories for source '{0}' from hoster '{1}'</value>
131125
</data>

0 commit comments

Comments
 (0)