mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-25 04:57:31 +00:00
fix: ignore trailing slash for autogenerated name (#7307)
- During the migration process, if a valid GitHub clone URL was pasted, https://github.com/yuvipanda/notebooksharing.space/, the form automatically generates an invalid Forgejo repository name that included the trailing slash. - Change the regex used to generate the name to ignore the trailing slash. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7307 Reviewed-by: Otto <otto@codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: YuviPanda <yuvipanda@gmail.com> Co-committed-by: YuviPanda <yuvipanda@gmail.com>
This commit is contained in:
parent
8df8381f51
commit
c9853e9e3a
2 changed files with 29 additions and 1 deletions
|
@ -7,6 +7,34 @@ import {test, save_visual, test_context} from './utils_e2e.ts';
|
|||
|
||||
test.use({user: 'user2'});
|
||||
|
||||
test('Migration Repo Name detection', async ({page}, workerInfo) => {
|
||||
test.skip(workerInfo.project.name === 'Mobile Safari', 'Flaky actionability checks on Mobile Safari');
|
||||
|
||||
await page.goto('/repo/migrate?service_type=2');
|
||||
|
||||
const form = page.locator('form');
|
||||
|
||||
// Test trailing slashes are stripped
|
||||
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).fill('https://github.com/example/test/');
|
||||
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).blur();
|
||||
await expect(form.getByRole('textbox', {name: 'Repository Name'})).toHaveValue('test');
|
||||
|
||||
// Test trailing .git is stripped
|
||||
await page.reload();
|
||||
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).fill('https://github.com/example/test.git');
|
||||
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).blur();
|
||||
await expect(form.getByRole('textbox', {name: 'Repository Name'})).toHaveValue('test');
|
||||
|
||||
// Test trailing .git and trailing / together is stripped
|
||||
await page.reload();
|
||||
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).fill('https://github.com/example/test.git/');
|
||||
await form.getByRole('textbox', {name: 'Migrate / Clone from URL'}).blur();
|
||||
await expect(form.getByRole('textbox', {name: 'Repository Name'})).toHaveValue('test');
|
||||
|
||||
// Save screenshot only once
|
||||
await save_visual(page);
|
||||
});
|
||||
|
||||
test('Migration Progress Page', async ({page, browser}, workerInfo) => {
|
||||
test.skip(workerInfo.project.name === 'Mobile Safari', 'Flaky actionability checks on Mobile Safari');
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export function initRepoMigration() {
|
|||
cloneAddr?.addEventListener('change', () => {
|
||||
const repoName = document.getElementById('repo_name');
|
||||
if (cloneAddr.value && !repoName?.value) { // Only modify if repo_name input is blank
|
||||
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?)$/)[3];
|
||||
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?\/?)$/)[3];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue