Browse Source

Remove sha1 hash display in repository table and add latest commit GPG check (#1678)

Lauris BH 2 years ago
parent
commit
2e17dda8bb
4 changed files with 57 additions and 33 deletions
  1. 14 7
      public/css/index.css
  2. 27 23
      public/less/_repository.less
  3. 1 0
      routers/repo/view.go
  4. 15 3
      templates/repo/view_list.tmpl

+ 14 - 7
public/css/index.css

@@ -1306,6 +1306,9 @@ footer .ui.language .menu {
1306 1306
   padding-top: 8px;
1307 1307
   padding-bottom: 8px;
1308 1308
 }
1309
+.repository.file.list #repo-files-table td.message .isSigned {
1310
+  cursor: default;
1311
+}
1309 1312
 .repository.file.list #repo-files-table tr:hover {
1310 1313
   background-color: #ffffEE;
1311 1314
 }
@@ -1933,10 +1936,15 @@ footer .ui.language .menu {
1933 1936
 .repository #commits-table td.sha .sha.label {
1934 1937
   margin: 0;
1935 1938
 }
1936
-.repository #commits-table td.sha .sha.label.isSigned {
1939
+.repository #commits-table.ui.basic.striped.table tbody tr:nth-child(2n) {
1940
+  background-color: rgba(0, 0, 0, 0.02) !important;
1941
+}
1942
+.repository #commits-table td.sha .sha.label.isSigned,
1943
+.repository #repo-files-table .sha.label.isSigned {
1937 1944
   border: 1px solid #BBB;
1938 1945
 }
1939
-.repository #commits-table td.sha .sha.label.isSigned .detail.icon {
1946
+.repository #commits-table td.sha .sha.label.isSigned .detail.icon,
1947
+.repository #repo-files-table .sha.label.isSigned .detail.icon {
1940 1948
   background: #FAFAFA;
1941 1949
   margin: -6px -10px -4px 0px;
1942 1950
   padding: 5px 3px 5px 6px;
@@ -1944,16 +1952,15 @@ footer .ui.language .menu {
1944 1952
   border-top-left-radius: 0;
1945 1953
   border-bottom-left-radius: 0;
1946 1954
 }
1947
-.repository #commits-table td.sha .sha.label.isSigned.isVerified {
1955
+.repository #commits-table td.sha .sha.label.isSigned.isVerified,
1956
+.repository #repo-files-table .sha.label.isSigned.isVerified {
1948 1957
   border: 1px solid #21BA45;
1949 1958
   background: #21BA4518;
1950 1959
 }
1951
-.repository #commits-table td.sha .sha.label.isSigned.isVerified .detail.icon {
1960
+.repository #commits-table td.sha .sha.label.isSigned.isVerified .detail.icon,
1961
+.repository #repo-files-table .sha.label.isSigned.isVerified .detail.icon {
1952 1962
   border-left: 1px solid #21BA4580;
1953 1963
 }
1954
-.repository #commits-table.ui.basic.striped.table tbody tr:nth-child(2n) {
1955
-  background-color: rgba(0, 0, 0, 0.02) !important;
1956
-}
1957 1964
 .repository .diff-detail-box {
1958 1965
   margin: 15px 0;
1959 1966
   line-height: 30px;

+ 27 - 23
public/less/_repository.less

@@ -204,6 +204,9 @@
204 204
 				padding-top: 8px;
205 205
 				padding-bottom: 8px;
206 206
 			}
207
+            td.message .isSigned {
208
+                cursor: default;
209
+            }
207 210
 			tr:hover {
208 211
 				background-color: #ffffEE;
209 212
 			}
@@ -804,34 +807,35 @@
804 807
 				width: 140px;
805 808
 			}
806 809
 		}
807
-		td.sha{
808
-			.sha.label{
809
-				margin: 0;
810
-				&.isSigned{
811
-					border: 1px solid #BBB;
812
-					.detail.icon{
813
-						background: #FAFAFA;
814
-						margin: -6px -10px -4px 0px;
815
-						padding: 5px 3px 5px 6px;
816
-						border-left: 1px solid #BBB;
817
-						border-top-left-radius: 0;
818
-						border-bottom-left-radius: 0;
819
-					}
820
-				}
821
-				&.isSigned.isVerified{
822
-					border: 1px solid #21BA45;
823
-					background: #21BA4518;
824
-					.detail.icon{
825
-						border-left: 1px solid #21BA4580;
826
-					}
827
-				}
828
-			}
829
-		}
810
+        td.sha .sha.label {
811
+            margin: 0;
812
+        }
830 813
 		&.ui.basic.striped.table tbody tr:nth-child(2n) {
831 814
 			background-color: rgba(0, 0, 0, .02)!important;
832 815
 		}
833 816
 	}
834 817
 
818
+    #commits-table td.sha .sha.label, #repo-files-table .sha.label{
819
+        &.isSigned{
820
+            border: 1px solid #BBB;
821
+            .detail.icon{
822
+                background: #FAFAFA;
823
+                margin: -6px -10px -4px 0px;
824
+                padding: 5px 3px 5px 6px;
825
+                border-left: 1px solid #BBB;
826
+                border-top-left-radius: 0;
827
+                border-bottom-left-radius: 0;
828
+            }
829
+        }
830
+        &.isSigned.isVerified{
831
+            border: 1px solid #21BA45;
832
+            background: #21BA4518;
833
+            .detail.icon{
834
+                border-left: 1px solid #21BA4580;
835
+            }
836
+        }
837
+    }
838
+
835 839
 	.diff-detail-box {
836 840
 		margin: 15px 0;
837 841
 		line-height: 30px;

+ 1 - 0
routers/repo/view.go

@@ -117,6 +117,7 @@ func renderDirectory(ctx *context.Context, treeLink string) {
117 117
 		}
118 118
 	}
119 119
 	ctx.Data["LatestCommit"] = latestCommit
120
+	ctx.Data["LatestCommitVerification"] = models.ParseCommitWithSignature(latestCommit)
120 121
 	ctx.Data["LatestCommitUser"] = models.ValidateCommitWithEmail(latestCommit)
121 122
 
122 123
 	// Check permission to add or upload new file.

+ 15 - 3
templates/repo/view_list.tmpl

@@ -13,7 +13,18 @@
13 13
 					<img class="ui avatar image img-12" src="{{AvatarLink .LatestCommit.Author.Email}}" />
14 14
 					<strong>{{.LatestCommit.Author.Name}}</strong>
15 15
 				{{end}}
16
-				<a rel="nofollow" class="ui sha label" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}" rel="nofollow">{{ShortSha .LatestCommit.ID.String}}</a>
16
+				<a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified }} isVerified {{end}}{{end}}" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}">
17
+						{{ShortSha .LatestCommit.ID.String}}
18
+						{{if .LatestCommit.Signature}}
19
+							<div class="ui detail icon button">
20
+								{{if .LatestCommitVerification.Verified}}
21
+									<i title="{{.LatestCommitVerification.Reason}}" class="lock green icon"></i>
22
+								{{else}}
23
+									<i title="{{$.i18n.Tr .LatestCommitVerification.Reason}}" class="unlock icon"></i>
24
+								{{end}}
25
+							</div>
26
+						{{end}}
27
+				</a>
17 28
 				<span class="grey has-emoji">{{RenderCommitMessage false .LatestCommit.Summary .RepoLink $.Repository.ComposeMetas}}</span>
18 29
 			</th>
19 30
 			<th class="nine wide">
@@ -61,8 +72,9 @@
61 72
 					</td>
62 73
 				{{end}}
63 74
 				<td class="message collapsing has-emoji">
64
-					<a rel="nofollow" class="ui sha label" href="{{$.RepoLink}}/commit/{{$commit.ID}}">{{ShortSha $commit.ID.String}}</a>
65
-					{{RenderCommitMessage false $commit.Summary $.RepoLink $.Repository.ComposeMetas}}
75
+					<a rel="nofollow" href="{{$.RepoLink}}/commit/{{$commit.ID}}">
76
+						{{RenderCommitMessage false $commit.Summary $.RepoLink $.Repository.ComposeMetas}}
77
+					</a>
66 78
 				</td>
67 79
 				<td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td>
68 80
 			</tr>