Skip to content

Commit

Permalink
[Bug#sf1258] http git repo erroneously set to svn (#1047)
Browse files Browse the repository at this point in the history
* identify repo type using url

Signed-off-by: Damien Rembert <[email protected]>

* add tests to cover the changes

Signed-off-by: Damien Rembert <[email protected]>

* fix formatting

Signed-off-by: Damien Rembert <[email protected]>

---------

Signed-off-by: Damien Rembert <[email protected]>
  • Loading branch information
damien-rembert authored Jun 2, 2024
1 parent 20977a4 commit 8d32dc0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/org/omegat/core/team2/RemoteRepositoryFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public static String detectRepositoryType(String url) {
return "svn";
} else if (url.startsWith("git")) {
return "git";
} else if (url.startsWith("https://git")) {
return "git";
} else if (url.endsWith(".git")) {
return "git";
} else {
if (GITRemoteRepository2.isGitRepository(url)) {
return "git";
Expand Down
58 changes: 58 additions & 0 deletions test/src/org/omegat/core/team2/RemoteRepositoryFactoryTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**************************************************************************
OmegaT - Computer Assisted Translation (CAT) tool
with fuzzy matching, translation memory, keyword search,
glossaries, and translation leveraging into updated projects.
Copyright (C) 2024 Damien Rembert
Home page: https://www.omegat.org/
Support center: https://omegat.org/support
This file is part of OmegaT.
OmegaT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OmegaT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**************************************************************************/

package org.omegat.core.team2;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public final class RemoteRepositoryFactoryTest {

@Test
public void testDetectRepositoryType_svnPrefix() {
String url = "svn://example.com/repo";
assertEquals("svn", RemoteRepositoryFactory.detectRepositoryType(url));
}

@Test
public void testDetectRepositoryType_gitPrefix() {
String url = "git://example.com/repo";
assertEquals("git", RemoteRepositoryFactory.detectRepositoryType(url));
}

@Test
public void testDetectRepositoryType_httpsGitPrefix() {
String url = "https://git.example.com/repo";
assertEquals("git", RemoteRepositoryFactory.detectRepositoryType(url));
}

@Test
public void testDetectRepositoryType_gitSuffix() {
String url = "https://example.com/repo.git";
assertEquals("git", RemoteRepositoryFactory.detectRepositoryType(url));
}

}

0 comments on commit 8d32dc0

Please sign in to comment.