MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / getBitbucketReposFromConfig

Function getBitbucketReposFromConfig

packages/backend/src/bitbucket.ts:80–134  ·  view source on GitHub ↗
(config: BitbucketConnectionConfig)

Source from the content-addressed store, hash-verified

78}
79
80export const getBitbucketReposFromConfig = async (config: BitbucketConnectionConfig) => {
81 const token = config.token ?
82 await getTokenFromConfig(config.token) :
83 undefined;
84
85 if (config.deploymentType === 'server' && !config.url) {
86 throw new Error('URL is required for Bitbucket Server');
87 }
88
89 const client = config.deploymentType === 'server' ?
90 createBitbucketServerClient(config.url!, config.user, token) :
91 createBitbucketCloudClient(config.user, token);
92
93 let allRepos: BitbucketRepository[] = [];
94 let allWarnings: string[] = [];
95
96 if (config.all === true) {
97 if (client.deploymentType === BITBUCKET_SERVER) {
98 const { repos, warnings } = await serverGetAllRepos(client);
99 allRepos = allRepos.concat(repos);
100 allWarnings = allWarnings.concat(warnings);
101 } else {
102 const warning = `Ignoring option all:true in config: not supported for Bitbucket Cloud`;
103 logger.warn(warning);
104 allWarnings = allWarnings.concat(warning);
105 }
106 }
107
108 if (config.workspaces) {
109 const { repos, warnings } = await client.getReposForWorkspace(client, config.workspaces);
110 allRepos = allRepos.concat(repos);
111 allWarnings = allWarnings.concat(warnings);
112 }
113
114 if (config.projects) {
115 const { repos, warnings } = await client.getReposForProjects(client, config.projects);
116 allRepos = allRepos.concat(repos);
117 allWarnings = allWarnings.concat(warnings);
118 }
119
120 if (config.repos) {
121 const { repos, warnings } = await client.getRepos(client, config.repos);
122 allRepos = allRepos.concat(repos);
123 allWarnings = allWarnings.concat(warnings);
124 }
125
126 const filteredRepos = allRepos.filter((repo) => {
127 return !client.shouldExcludeRepo(repo, config);
128 });
129
130 return {
131 repos: filteredRepos,
132 warnings: allWarnings,
133 };
134}
135
136export function createBitbucketCloudClient(user: string | undefined, token: string | undefined): BitbucketClient {
137 const authorizationString =

Callers 1

compileBitbucketConfigFunction · 0.85

Calls 4

getTokenFromConfigFunction · 0.90
serverGetAllReposFunction · 0.85

Tested by

no test coverage detected