Skip to content

Commit

Permalink
fix: getGitRepoOptionsFromLocation method (#1104)
Browse files Browse the repository at this point in the history
* fix: getGitRepoOptionsFromLocation method

Signed-off-by: Oleksii Orel <oorel@redhat.com>
  • Loading branch information
olexii4 authored May 2, 2024
1 parent b48d98b commit 0125fb5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions .deps/EXCLUDED/prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ This file lists dependencies that do not need CQs or auto-detection does not wor
| `cookie-signature@1.2.1` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/cookie-signature/1.2.1) |
| `fast-uri@2.3.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fast-uri/2.3.0) |
| `fastify@4.26.2` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fastify/4.26.2) |
| `jsbn@0.1.1` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/jsbn/0.1.1) |
| `real-require@0.2.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/real-require/0.2.0) |
10 changes: 5 additions & 5 deletions .deps/prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
| [`@babel/runtime@7.23.2`](https://github.com/babel/babel.git) | MIT | #10718 |
| [`@devfile/api@2.2.2-1700686170`](https://github.com/GIT_USER_ID/GIT_REPO_ID.git) | Apache-2.0 | clearlydefined |
| [`@eclipse-che/che-devworkspace-generator@7.79.0-next-1427c19`](git+https://github.com/eclipse-che/che-devfile-registry.git) | EPL-2.0 | ecd.che |
| [`@eclipse-che/common@7.85.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-backend@7.85.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-frontend@7.85.0-next`](git://github.com/eclipse/che-dashboard.git) | EPL-2.0 | ecd.che |
| [`@eclipse-che/common@7.86.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-backend@7.86.0-next`](https://github.com/eclipse-che/che-dashboard) | EPL-2.0 | ecd.che |
| [`@eclipse-che/dashboard-frontend@7.86.0-next`](git://github.com/eclipse/che-dashboard.git) | EPL-2.0 | ecd.che |
| [`@fastify/accept-negotiator@1.1.0`](git+https://github.com/fastify/accept-negotiator.git) | MIT | clearlydefined |
| [`@fastify/ajv-compiler@3.5.0`](git+https://github.com/fastify/ajv-compiler.git) | MIT | clearlydefined |
| [`@fastify/busboy@2.0.0`](https://github.com/fastify/busboy.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -108,7 +108,7 @@
| [`create-hmac@1.1.7`](https://github.com/crypto-browserify/createHmac.git) | MIT | clearlydefined |
| [`crypto-browserify@3.12.0`](git://github.com/crypto-browserify/crypto-browserify.git) | MIT | #1033 |
| [`csstype@3.1.2`](https://github.com/frenic/csstype) | MIT | #11847 |
| [`dashdash@1.14.1`](git://github.com/trentm/node-dashdash.git) | MIT | clearlydefined |
| [`dashdash@1.14.1`](git://github.com/trentm/node-dashdash.git) | MIT | #14596 |
| [`date-fns@2.30.0`](https://github.com/date-fns/date-fns) | MIT | clearlydefined |
| [`dateformat@4.6.3`](https://github.com/felixge/node-dateformat.git) | MIT | clearlydefined |
| [`debug@4.3.4`](git://github.com/debug-js/debug.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -200,7 +200,7 @@
| [`joycon@3.1.1`](https://github.com/egoist/joycon.git) | MIT | clearlydefined |
| [`js-tokens@4.0.0`](https://github.com/lydell/js-tokens.git) | MIT | #2401 |
| [`js-yaml@4.1.0`](https://github.com/nodeca/js-yaml.git) | MIT | clearlydefined |
| [`jsbn@0.1.1`](https://github.com/andyperlitch/jsbn.git) | MIT | clearlydefined |
| [`jsbn@0.1.1`](https://github.com/andyperlitch/jsbn.git) | MIT | |
| [`json-schema-ref-resolver@1.0.1`](git+https://github.com/fastify/json-schema-ref-resolver.git) | MIT | clearlydefined |
| [`json-schema-resolver@2.0.0`](git+https://github.com/Eomm/json-schema-resolver.git) | MIT | clearlydefined |
| [`json-schema-traverse@1.0.0`](git+https://github.com/epoberezkin/json-schema-traverse.git) | MIT | clearlydefined |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('helpers', () => {
const options = helpers.getGitRepoOptionsFromLocation(location);
expect(options).toEqual({
location:
'https://github.com/eclipse-che/che-dashboard/tree/main?remotes=%7B%7Btest-1%2Chttp%3A%2F%2Ftest-1.git%7D%7D&override.devfileFilename=devfile2.yaml',
'https://github.com/eclipse-che/che-dashboard/tree/main?remotes=%7B%7Btest-1%2Chttp%3A%2F%2Ftest-1.git%7D%7D&devfilePath=devfile2.yaml',
hasSupportedGitService: true,
gitBranch: 'main',
remotes: [{ name: 'test-1', url: 'http://test-1.git' }],
Expand All @@ -263,7 +263,7 @@ describe('helpers', () => {
const options = helpers.getGitRepoOptionsFromLocation(location);
expect(options).toEqual({
location:
'git@github.com:eclipse-che/che-dashboard.git?remotes=%7B%7Btest-1%2Chttp%3A%2F%2Ftest-1.git%7D%7D&override.devfileFilename=devfile2.yaml',
'git@github.com:eclipse-che/che-dashboard.git?remotes=%7B%7Btest-1%2Chttp%3A%2F%2Ftest-1.git%7D%7D&devfilePath=devfile2.yaml',
hasSupportedGitService: false,
gitBranch: undefined,
remotes: [{ name: 'test-1', url: 'http://test-1.git' }],
Expand All @@ -279,7 +279,7 @@ describe('helpers', () => {
const options = helpers.getGitRepoOptionsFromLocation(location);
expect(options).toEqual({
location:
'https://not-supported.com?remotes=%7B%7Btest-1%2Chttp%3A%2F%2Ftest-1.git%7D%7D&override.devfileFilename=devfile2.yaml',
'https://not-supported.com?remotes=%7B%7Btest-1%2Chttp%3A%2F%2Ftest-1.git%7D%7D&devfilePath=devfile2.yaml',
hasSupportedGitService: false,
gitBranch: undefined,
remotes: [{ name: 'test-1', url: 'http://test-1.git' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ export function getGitRepoOptionsFromLocation(location: string): {
const params = decodeURIComponent(factoryLoaderPath.split('?')[1] || '');
const searchParams = new URLSearchParams(params);
searchParams.delete('url');
let devfilePath = searchParams.get('override.devfileFilename') || undefined;
if (devfilePath === 'true') {
const devfilePath = searchParams.get('override.devfileFilename') || undefined;
if (devfilePath !== 'true' && devfilePath) {
searchParams.set('devfilePath', devfilePath);
}
if (searchParams.has('override.devfileFilename')) {
searchParams.delete('override.devfileFilename');
devfilePath = undefined;
}
let remotes: GitRemote[] | undefined;
const _remotes = searchParams.get('remotes') || undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ImportFromGit extends React.PureComponent<Props, State> {

private handleCreate(): void {
const { editorDefinition, editorImage } = this.props;
const { location } = this.state;
const location = decodeURIComponent(this.state.location);

const factory = new FactoryLocationAdapter(location);

Expand Down

0 comments on commit 0125fb5

Please sign in to comment.