feat(repository): display branches and tags in RepositoryDetailsView
+ 72
- 35
@@ -1,5 +1,5 @@
 {
-  "_generatedAtUnix": 1663845732496,
+  "_generatedAtUnix": 1663967797508,
   "_hashAlgorithm": "sha1",
   "_version": 2,
   "islands": {

...
@@ -78,7 +78,7 @@
       "pathSource": "./app/views/repository/RepositoryCreateView.tsx"
     },
     "RepositoryDetailsView": {
-      "hash": "96dd6b16b4a39ab559f92ca8489c25bbaa545567",
+      "hash": "2abf6abfa4d4d2b306a3e3e5ceb8e3fbc2f254cc",
       "pathSource": "./app/views/repository/RepositoryDetailsView.tsx"
     },
     "RepositoryExploreView": {

app/controllers/repository/getRepositoryDetailsView.ts
@@ -52,12 +52,17 @@ const getRepositoryDetailsView: ReqHandler = async (request, reply) => {
     ref,
     true
   );
+
   const lastCommit = commitLogs.length >= 1 ? commitLogs[0] : null;
 
+  const branches = await repoService.getRepositoryBranches(repo);
+  const tags = await repoService.getRepositoryTags(repo);
+
   const reqHandler = reply.makeRequestHandler(request, reply);
 
   try {
     return reqHandler<RepositoryDetailsViewProps>(RepositoryDetailsView.name, {
+      branches,
       currentUser,
       cloneUrl: {
         http: await repoService.getRepositoryHTTPCloneUrl(repo),

...
@@ -71,6 +76,7 @@ const getRepositoryDetailsView: ReqHandler = async (request, reply) => {
       repo,
       repoHead: await repoService.getRepositoryHead(repo, ref),
       repoFiles: await repoService.getRepositoryFiles(repo, "", ref),
+      tags,
     });
   } catch (err) {
     const error = err as Error;

...
@@ -78,6 +84,7 @@ const getRepositoryDetailsView: ReqHandler = async (request, reply) => {
       return reqHandler<RepositoryDetailsViewProps>(
         RepositoryDetailsView.name,
         {
+          branches,
           currentUser,
           cloneUrl: {
             http: await repoService.getRepositoryHTTPCloneUrl(repo),

...
@@ -90,6 +97,7 @@ const getRepositoryDetailsView: ReqHandler = async (request, reply) => {
           repo,
           repoHead: null,
           repoFiles: [],
+          tags,
         }
       );
     } else if (

app/services/repository/getRepositoryTags.ts
@@ -36,7 +36,7 @@ const makeGetRepositoryTags: ServiceMethodFactory<
         );
       }
 
-      const gitTagProcess = spawn("git", ["tag", "--sort=taggerdate"], {
+      const gitTagProcess = spawn("git", ["tag", "--sort=-v:refname"], {
         cwd: repoPath,
       });
 

app/views/repository/RepositoryDetailsView.tsx
@@ -24,6 +24,7 @@ import RepositoryInitialSetup from "../../islands/RepositoryInitialSetup";
 import RepositoryTreeView from "../../islands/RepositoryTreeView";
 
 export interface RepositoryDetailsViewProps extends CommonProps {
+  branches: string[];
   currentUser: null | User;
   cloneUrl: {
     http: string;

...
@@ -37,9 +38,11 @@ export interface RepositoryDetailsViewProps extends CommonProps {
   repo: Repository;
   repoHead: null | RepositoryHead;
   repoFiles: RepositoryFile[];
+  tags: string[];
 }
 
 const RepositoryDetailsView: ReactView<RepositoryDetailsViewProps> = ({
+  branches,
   currentUser,
   commonProps,
   cloneUrl,

...
@@ -51,6 +54,7 @@ const RepositoryDetailsView: ReactView<RepositoryDetailsViewProps> = ({
   repo,
   repoHead,
   repoFiles,
+  tags,
 }) => {
   return (
     <Layout {...commonProps}>

...
@@ -121,40 +125,65 @@ const RepositoryDetailsView: ReactView<RepositoryDetailsViewProps> = ({
               style={{ width: "100%" }}
               themeScheme={commonProps.themeScheme}
             >
-              <div>
-                <p>{repo.shortDescription}</p>
-                {repo.websiteUrl != null && (
-                  <p>
-                    <a
-                      href={repo.websiteUrl}
-                      target={"_blank"}
-                      rel={"noopener noreferer noreferrer"}
-                    >
-                      {repo.websiteUrl}
-                    </a>
-                  </p>
-                )}
-              </div>
-              <div>
-                {repo.keywords.map((keyword, idx, arr) => (
-                  <React.Fragment key={[idx, keyword].join(":")}>
-                    <span>{keyword}</span>
-                    {idx < arr.length - 1 ? ", " : "."}
-                  </React.Fragment>
-                ))}
-              </div>
-              <div>
-                <p>
-                  <strong>HTTP Clone:</strong>
-                  <br />
-                  <code>{cloneUrl.http}</code>
-                </p>
+              <p>{repo.shortDescription}</p>
+              {repo.websiteUrl != null && (
                 <p>
-                  <strong>SSH Clone:</strong>
-                  <br />
-                  <code>{cloneUrl.ssh}</code>
+                  <a
+                    href={repo.websiteUrl}
+                    target={"_blank"}
+                    rel={"noopener noreferer noreferrer"}
+                  >
+                    {repo.websiteUrl}
+                  </a>
                 </p>
-              </div>
+              )}
+              <p>
+                {repo.keywords.map(
+                  (keyword, idx, arr) =>
+                    keyword.trim() !== "" && (
+                      <React.Fragment key={[idx, keyword].join(":")}>
+                        <span>{keyword}</span>
+                        {idx < arr.length - 2 ? ", " : "."}
+                      </React.Fragment>
+                    )
+                )}
+              </p>
+              <p>
+                <strong>HTTP Clone:</strong>
+                <br />
+                <code>{cloneUrl.http}</code>
+              </p>
+              <p>
+                <strong>SSH Clone:</strong>
+                <br />
+                <code>{cloneUrl.ssh}</code>
+              </p>
+              <p>
+                <strong>Branches:</strong>
+                <br />
+                {branches.map(
+                  (branch, idx, self) =>
+                    branch.trim() != "" && (
+                      <React.Fragment key={branch}>
+                        <span>{branch}</span>
+                        {idx < self.length - 2 ? ", " : "."}
+                      </React.Fragment>
+                    )
+                )}
+              </p>
+              <p>
+                <strong>Tags:</strong>
+                <br />
+                {tags.map(
+                  (tag, idx, self) =>
+                    tag.trim() != "" && (
+                      <React.Fragment key={tag}>
+                        <span>{tag}</span>
+                        {idx < self.length - 2 ? ", " : "."}
+                      </React.Fragment>
+                    )
+                )}
+              </p>
             </Card>
           </Grid.Col>
         </Grid.Row>