-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of ssh://github.com/mlhartme/pommes
- Loading branch information
Showing
23 changed files
with
374 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Java CI with Maven | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: maven-settings-xml-action | ||
uses: whelk-io/maven-settings-xml-action@v4 | ||
with: | ||
repositories: '[{ "id": "oss-sonatype-snapshot", "name": "oss-sonatype-snapshot", "url": "https://oss.sonatype.org/content/repositories/snapshots/" }]' | ||
- name: Build with Maven | ||
run: mvn -B -U clean package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/net/oneandone/pommes/repository/Constructor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package net.oneandone.pommes.repository; | ||
|
||
import net.oneandone.pommes.cli.Environment; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.net.URISyntaxException; | ||
|
||
@FunctionalInterface | ||
public interface Constructor { | ||
Repository create(Environment environment, String name, String url, PrintWriter log) throws URISyntaxException, IOException; | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/net/oneandone/pommes/repository/GiteaProject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.oneandone.pommes.repository; | ||
|
||
import io.gitea.ApiException; | ||
import io.gitea.api.RepositoryApi; | ||
import io.gitea.model.ContentsResponse; | ||
import net.oneandone.pommes.cli.Environment; | ||
import net.oneandone.pommes.descriptor.Descriptor; | ||
import net.oneandone.pommes.scm.GitUrl; | ||
import net.oneandone.sushi.fs.memory.MemoryNode; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
import java.util.List; | ||
|
||
public record GiteaProject(String org, String repo, String ref) { | ||
public Descriptor scanOpt(Environment environment, String hostname, RepositoryApi repositoryApi) throws IOException, ApiException { | ||
List<ContentsResponse> lst; | ||
|
||
lst = repositoryApi.repoGetContentsList(org, repo, ref); | ||
for (ContentsResponse contents : lst) { | ||
if ("file".equals(contents.getType())) { | ||
Descriptor.Creator m = Descriptor.match(contents.getName()); | ||
if (m != null) { | ||
contents = repositoryApi.repoGetContents(org, repo, contents.getPath(), ref); | ||
String str = contents.getContent(); | ||
if ("base64".equals(contents.getEncoding())) { | ||
str = new String(Base64.getDecoder().decode(str.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8); | ||
} else if (contents.getEncoding() != null) { | ||
throw new IllegalStateException(contents.getEncoding()); | ||
} | ||
MemoryNode tmp = environment.world().memoryNode(str); | ||
return m.create(environment, tmp, repo, org + "/" + repo + "/" + contents.getPath(), tmp.sha(), | ||
GitUrl.create("ssh://gitea@" + hostname + "/" + org + "/" + repo + ".git")); | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.