Skip to content

Commit

Permalink
Add more Repository attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Aug 31, 2024
1 parent cf50f37 commit f9af54a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ public class Repository extends BaseGitServiceEntity {
@NonNull
private String description;

@NonNull
String defaultBranch;

@NonNull
private RepositoryVisibility visibility;

@NonNull
private String url;

String homepage;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "repository", fetch = FetchType.EAGER)
@ToString.Exclude
private Set<PullRequest> pullRequests = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.tum.in.www1.hephaestus.codereview.repository;

import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GHRepository.Visibility;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
Expand All @@ -21,7 +22,20 @@ public Repository convert(@NonNull GHRepository source) {
repository.setNameWithOwner(source.getFullName());
repository.setDescription(source.getDescription());
repository.setUrl(source.getHtmlUrl().toString());
repository.setDefaultBranch(source.getDefaultBranch());
repository.setVisibility(convertVisibility(source.getVisibility()));
repository.setHomepage(source.getHomepage());
return repository;
}

private RepositoryVisibility convertVisibility(Visibility visibility) {
switch (visibility) {
case PRIVATE:
return RepositoryVisibility.PRIVATE;
case PUBLIC:
return RepositoryVisibility.PUBLIC;
default:
return RepositoryVisibility.PRIVATE;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.tum.in.www1.hephaestus.codereview.repository;

public enum RepositoryVisibility {
PUBLIC, PRIVATE
}

0 comments on commit f9af54a

Please sign in to comment.