Fossil SCM

Provide method to obtain a plaintext hash of an artifact; can be used by build monitors to determine if a given branch hash new changes to consume.

andybradford 2025-03-25 02:32 trunk merge
Commit 4956789576c0578752aedbcb0ae619f1311cf0397798b92f8b2518419b5f9f28
1 file changed +10
+10
--- src/info.c
+++ src/info.c
@@ -2643,10 +2643,11 @@
26432643
** filename=NAME - alternative spelling for "name="
26442644
** fn=NAME - alternative spelling for "name="
26452645
** ci=VERSION - The specific check-in to use with "name=" to
26462646
** identify the file.
26472647
** txt - Force display of unformatted source text
2648
+** hash - Output only the hash of the artifact
26482649
**
26492650
** The /artifact page show the complete content of a file
26502651
** identified by HASH. The /whatis page shows only a description
26512652
** of how the artifact is used. The /file page shows the most recent
26522653
** version of the file or directory called NAME, or a list of the
@@ -2665,18 +2666,20 @@
26652666
void artifact_page(void){
26662667
int rid = 0;
26672668
Blob content;
26682669
const char *zMime;
26692670
Blob downloadName;
2671
+ Blob uuid;
26702672
int renderAsWiki = 0;
26712673
int renderAsHtml = 0;
26722674
int renderAsSvg = 0;
26732675
int objType;
26742676
int asText;
26752677
const char *zUuid = 0;
26762678
u32 objdescFlags = OBJDESC_BASE;
26772679
int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
2680
+ int hashOnly = P("hash")!=0;
26782681
int isFile = fossil_strcmp(g.zPath,"file")==0;
26792682
const char *zLn = P("ln");
26802683
const char *zName = P("name");
26812684
const char *zCI = P("ci");
26822685
HQuery url;
@@ -2789,10 +2792,17 @@
27892792
url_add_parameter(&url, "verbose", "1");
27902793
objdescFlags |= OBJDESC_DETAIL;
27912794
}
27922795
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
27932796
etag_check(ETAG_HASH, zUuid);
2797
+
2798
+ if( descOnly && hashOnly ){
2799
+ blob_set(&uuid, zUuid);
2800
+ cgi_set_content_type("text/plain");
2801
+ cgi_set_content(&uuid);
2802
+ return;
2803
+ }
27942804
27952805
asText = P("txt")!=0;
27962806
if( isFile ){
27972807
if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
27982808
zCI = "tip";
27992809
--- src/info.c
+++ src/info.c
@@ -2643,10 +2643,11 @@
2643 ** filename=NAME - alternative spelling for "name="
2644 ** fn=NAME - alternative spelling for "name="
2645 ** ci=VERSION - The specific check-in to use with "name=" to
2646 ** identify the file.
2647 ** txt - Force display of unformatted source text
 
2648 **
2649 ** The /artifact page show the complete content of a file
2650 ** identified by HASH. The /whatis page shows only a description
2651 ** of how the artifact is used. The /file page shows the most recent
2652 ** version of the file or directory called NAME, or a list of the
@@ -2665,18 +2666,20 @@
2665 void artifact_page(void){
2666 int rid = 0;
2667 Blob content;
2668 const char *zMime;
2669 Blob downloadName;
 
2670 int renderAsWiki = 0;
2671 int renderAsHtml = 0;
2672 int renderAsSvg = 0;
2673 int objType;
2674 int asText;
2675 const char *zUuid = 0;
2676 u32 objdescFlags = OBJDESC_BASE;
2677 int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
 
2678 int isFile = fossil_strcmp(g.zPath,"file")==0;
2679 const char *zLn = P("ln");
2680 const char *zName = P("name");
2681 const char *zCI = P("ci");
2682 HQuery url;
@@ -2789,10 +2792,17 @@
2789 url_add_parameter(&url, "verbose", "1");
2790 objdescFlags |= OBJDESC_DETAIL;
2791 }
2792 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
2793 etag_check(ETAG_HASH, zUuid);
 
 
 
 
 
 
 
2794
2795 asText = P("txt")!=0;
2796 if( isFile ){
2797 if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
2798 zCI = "tip";
2799
--- src/info.c
+++ src/info.c
@@ -2643,10 +2643,11 @@
2643 ** filename=NAME - alternative spelling for "name="
2644 ** fn=NAME - alternative spelling for "name="
2645 ** ci=VERSION - The specific check-in to use with "name=" to
2646 ** identify the file.
2647 ** txt - Force display of unformatted source text
2648 ** hash - Output only the hash of the artifact
2649 **
2650 ** The /artifact page show the complete content of a file
2651 ** identified by HASH. The /whatis page shows only a description
2652 ** of how the artifact is used. The /file page shows the most recent
2653 ** version of the file or directory called NAME, or a list of the
@@ -2665,18 +2666,20 @@
2666 void artifact_page(void){
2667 int rid = 0;
2668 Blob content;
2669 const char *zMime;
2670 Blob downloadName;
2671 Blob uuid;
2672 int renderAsWiki = 0;
2673 int renderAsHtml = 0;
2674 int renderAsSvg = 0;
2675 int objType;
2676 int asText;
2677 const char *zUuid = 0;
2678 u32 objdescFlags = OBJDESC_BASE;
2679 int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
2680 int hashOnly = P("hash")!=0;
2681 int isFile = fossil_strcmp(g.zPath,"file")==0;
2682 const char *zLn = P("ln");
2683 const char *zName = P("name");
2684 const char *zCI = P("ci");
2685 HQuery url;
@@ -2789,10 +2792,17 @@
2792 url_add_parameter(&url, "verbose", "1");
2793 objdescFlags |= OBJDESC_DETAIL;
2794 }
2795 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
2796 etag_check(ETAG_HASH, zUuid);
2797
2798 if( descOnly && hashOnly ){
2799 blob_set(&uuid, zUuid);
2800 cgi_set_content_type("text/plain");
2801 cgi_set_content(&uuid);
2802 return;
2803 }
2804
2805 asText = P("txt")!=0;
2806 if( isFile ){
2807 if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){
2808 zCI = "tip";
2809

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button