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

[PRD] TCI/Assembla Handshake with SVN/P4 #2778

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/adapters/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ export default V3Adapter.extend({
const prefix = this.urlPrefix();

if (query) {
const { provider, slug, custom } = query;
const { provider, slug, serverType, custom } = query;
const providerPrefix = provider ? `${provider}/` : '';

delete query.provider;
delete query.slug;
delete query.custom;
delete query.serverType;

// fetch repo by slug
if (!id && slug) {
return `${prefix}/repo/${providerPrefix}${encodeURIComponent(slug)}`;
let url = `${prefix}/repo/${providerPrefix}${encodeURIComponent(slug)}`;
if (serverType) {
url = `${url}?server_type=${serverType}`;
}
return url;
}

if (custom && custom.type === 'byOwner') {
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default Controller.extend({
features: service(),
updateTimesService: service('updateTimes'),

queryParams: ['migrationStatus'],
queryParams: ['migrationStatus', 'serverType'],
serverType: null,
migrationStatus: null,

jobController: controller('job'),
Expand Down
9 changes: 6 additions & 3 deletions app/models/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,15 @@ Repo.reopenClass({
});
},

fetchBySlug(store, slug, provider = defaultVcsConfig.urlPrefix) {
const loadedRepos = store.peekAll('repo').filterBy('provider', provider).filterBy('slug', slug);
fetchBySlug(store, slug, provider = defaultVcsConfig.urlPrefix, serverType = undefined) {
let loadedRepos = store.peekAll('repo').filterBy('provider', provider).filterBy('slug', slug);
if (serverType) {
loadedRepos = loadedRepos.filterBy('serverType', serverType);
}
if (!isEmpty(loadedRepos)) {
return EmberPromise.resolve(loadedRepos.firstObject);
}
return store.queryRecord('repo', { slug, provider });
return store.queryRecord('repo', { slug, provider, serverType });
},
});

Expand Down
2 changes: 2 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ Router.map(function () {
this.route('legacy-repo-url', { path: '/:owner/:repo/:method' });
this.route('legacy-repo-url', { path: '/:owner/:repo/:method/:id' });
this.route('legacy-repo-url', { path: '/:owner/:repo/:method/:id/:view' });
this.route('legacy-repo-url', { path: '/:provider/:owner/:repo/:serverType/:method/:id' });
this.route('legacy-repo-url', { path: '/:provider/:owner/:repo/:serverType/:method/:id/:view' });

this.route('error404', { path: '/404' });
this.route('page-not-found', { path: '/*wildcard' });
Expand Down
23 changes: 18 additions & 5 deletions app/routes/legacy-repo-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,32 @@ export default Route.extend({

beforeModel(transition) {
const { params, queryParams } = transition.to;
let { owner, repo, method, id, view } = params;
let provider, routeName = 'provider', routeModels = [];
let { owner, repo, method, id, view, provider, serverType } = params;
let vcsConfig, routeName = 'provider', routeModels = [];

const vcsConfig = vcsConfigByUrlPrefix(owner);
if (provider) {
vcsConfig = vcsConfigByUrlPrefix(provider);
} else {
vcsConfig = vcsConfigByUrlPrefix(owner);
}

const isLegacyUrl = isEmpty(vcsConfig);
const serverTypes = ['git', 'svn', 'perforce'];
const isServerTypeUrl = serverTypes.includes(serverType) || serverTypes.includes(id);

if (isLegacyUrl) {
provider = defaultVcsConfig.urlPrefix;
} else {
// params include provider, so swap them accordingly
[provider, owner, repo, method, id] = [owner, repo, method, id, view];
if (!isServerTypeUrl) {
[provider, owner, repo, method, id] = [owner, repo, method, id, view];
} else if (serverTypes.includes(id)) {
[provider, owner, repo, serverType, method, id, view] = [owner, repo, method, id, view];
}
}

const newQueryParams = { serverType: serverType, ...queryParams };

routeModels.push(provider);

if (owner) {
Expand All @@ -43,7 +56,7 @@ export default Route.extend({

if (this._router.hasRoute(routeName)) {
transition.abort();
this.transitionTo(routeName, ...routeModels, { queryParams });
this.transitionTo(routeName, ...routeModels, { queryParams: newQueryParams });
}
}
});
4 changes: 2 additions & 2 deletions app/routes/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export default TravisRoute.extend(ScrollResetMixin, {
return { provider, owner, name };
},

model({ provider, owner, name }) {
model({ provider, owner, name, serverType }) {
const slug = `${owner}/${name}`;
this.set('slug', slug);
return Repo.fetchBySlug(this.store, slug, provider);
return Repo.fetchBySlug(this.store, slug, provider, serverType);
},

beforeModel() {
Expand Down