Fossil SCM
Add --wiki-file and --wiki-mimetype options to the ci command.
Commit
94e16bea4dce8331fabe5074ecb0c2e6eb648b0b69fa78d873fe9a4da0cddc53
Parent
219539c4707f84b…
1 file changed
+33
-1
+33
-1
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -2442,11 +2442,11 @@ | ||
| 2442 | 2442 | blob_reset(&txt); |
| 2443 | 2443 | } |
| 2444 | 2444 | blob_reset(&html); |
| 2445 | 2445 | blob_reset(&in); |
| 2446 | 2446 | return rc; |
| 2447 | -} | |
| 2447 | +} | |
| 2448 | 2448 | |
| 2449 | 2449 | /* |
| 2450 | 2450 | ** COMMAND: ci# |
| 2451 | 2451 | ** COMMAND: commit |
| 2452 | 2452 | ** |
| @@ -2534,10 +2534,16 @@ | ||
| 2534 | 2534 | ** --proxy PROXY Use PROXY as http proxy during sync operation |
| 2535 | 2535 | ** --tag TAG-NAME Add TAG-NAME to the check-in. May be repeated. |
| 2536 | 2536 | ** --trace Debug tracing |
| 2537 | 2537 | ** --user-override USER Record USER as the login that created the |
| 2538 | 2538 | ** new check-in, rather that the current user. |
| 2539 | +** --wiki-file FILE Adds FILE's content as a wiki page associated | |
| 2540 | +** with this check-in. | |
| 2541 | +** --wiki-mimetype TYPE Mimetype for --wiki-file. Default is from the | |
| 2542 | +** file extension: .md=markdown, .wiki=fossil, | |
| 2543 | +** otherwise plain text. Accepts "markdown", | |
| 2544 | +** "wiki", and "plain" as aliases. | |
| 2539 | 2545 | ** |
| 2540 | 2546 | ** See also: [[branch]], [[changes]], [[update]], [[extras]], [[sync]] |
| 2541 | 2547 | */ |
| 2542 | 2548 | void commit_cmd(void){ |
| 2543 | 2549 | int hasChanges; /* True if unsaved changes exist */ |
| @@ -2587,10 +2593,12 @@ | ||
| 2587 | 2593 | int bIgnoreSkew = 0; /* --ignore-clock-skew flag */ |
| 2588 | 2594 | int mxSize; |
| 2589 | 2595 | char *zCurBranch = 0; /* The current branch name of checkout */ |
| 2590 | 2596 | char *zNewBranch = 0; /* The branch name after update */ |
| 2591 | 2597 | int ckComFlgs; /* Flags passed to verify_comment() */ |
| 2598 | + const char * zWikiFile; /* --wiki-file X */ | |
| 2599 | + const char * zWikiMime; /* --wiki-mimetype X */ | |
| 2592 | 2600 | |
| 2593 | 2601 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 2594 | 2602 | url_proxy_options(); |
| 2595 | 2603 | /* Undocumented. Supported only for backwards |
| 2596 | 2604 | ** compatibility -------vvvvvvv */ |
| @@ -2655,10 +2663,12 @@ | ||
| 2655 | 2663 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 2656 | 2664 | useCksum = db_get_boolean("repo-cksum", 1); |
| 2657 | 2665 | bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0; |
| 2658 | 2666 | mxSize = db_large_file_size(); |
| 2659 | 2667 | if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0; |
| 2668 | + zWikiFile = find_option("wiki-file",0,1); | |
| 2669 | + zWikiMime = find_option("wiki-mimetype",0,1); | |
| 2660 | 2670 | (void)fossil_text_editor(); |
| 2661 | 2671 | verify_all_options(); |
| 2662 | 2672 | |
| 2663 | 2673 | /* The --no-warnings flag and the --force flag each imply |
| 2664 | 2674 | ** the --no-verify-comment flag */ |
| @@ -3305,10 +3315,32 @@ | ||
| 3305 | 3315 | vfile_aggregate_checksum_disk(nvid, &cksum2); |
| 3306 | 3316 | if( blob_compare(&cksum1, &cksum2) ){ |
| 3307 | 3317 | fossil_fatal("working check-out before and after commit does not match"); |
| 3308 | 3318 | } |
| 3309 | 3319 | } |
| 3320 | + | |
| 3321 | + if( zWikiFile ){ | |
| 3322 | + /* Handle --wiki-file and --wiki-mimetype */ | |
| 3323 | + Blob bWiki = BLOB_INITIALIZER; | |
| 3324 | + char * zPageName; | |
| 3325 | + blob_read_from_file(&bWiki, zWikiFile, ExtFILE); | |
| 3326 | + if( !zWikiMime ){ | |
| 3327 | + if( 0==sqlite3_strglob("*.md", zWikiFile) ){ | |
| 3328 | + zWikiMime = "text/x-markdown"; | |
| 3329 | + }else if( 0==sqlite3_strglob("*.wiki", zWikiFile) ){ | |
| 3330 | + zWikiMime = "text/x-fossil-wiki"; | |
| 3331 | + }else{ | |
| 3332 | + zWikiMime = "text/plain"; | |
| 3333 | + } | |
| 3334 | + } | |
| 3335 | + zWikiMime = wiki_filter_mimetypes(zWikiMime); | |
| 3336 | + zPageName = mprintf("checkin/%s", zUuid); | |
| 3337 | + wiki_cmd_commit(zPageName, 0, &bWiki, zWikiMime, 0); | |
| 3338 | + fossil_print("Added %s (%s)\n", zPageName, zWikiMime); | |
| 3339 | + blob_reset(&bWiki); | |
| 3340 | + fossil_free(zPageName); | |
| 3341 | + } | |
| 3310 | 3342 | |
| 3311 | 3343 | /* Clear the undo/redo stack */ |
| 3312 | 3344 | undo_reset(); |
| 3313 | 3345 | |
| 3314 | 3346 | /* Commit */ |
| 3315 | 3347 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -2442,11 +2442,11 @@ | |
| 2442 | blob_reset(&txt); |
| 2443 | } |
| 2444 | blob_reset(&html); |
| 2445 | blob_reset(&in); |
| 2446 | return rc; |
| 2447 | } |
| 2448 | |
| 2449 | /* |
| 2450 | ** COMMAND: ci# |
| 2451 | ** COMMAND: commit |
| 2452 | ** |
| @@ -2534,10 +2534,16 @@ | |
| 2534 | ** --proxy PROXY Use PROXY as http proxy during sync operation |
| 2535 | ** --tag TAG-NAME Add TAG-NAME to the check-in. May be repeated. |
| 2536 | ** --trace Debug tracing |
| 2537 | ** --user-override USER Record USER as the login that created the |
| 2538 | ** new check-in, rather that the current user. |
| 2539 | ** |
| 2540 | ** See also: [[branch]], [[changes]], [[update]], [[extras]], [[sync]] |
| 2541 | */ |
| 2542 | void commit_cmd(void){ |
| 2543 | int hasChanges; /* True if unsaved changes exist */ |
| @@ -2587,10 +2593,12 @@ | |
| 2587 | int bIgnoreSkew = 0; /* --ignore-clock-skew flag */ |
| 2588 | int mxSize; |
| 2589 | char *zCurBranch = 0; /* The current branch name of checkout */ |
| 2590 | char *zNewBranch = 0; /* The branch name after update */ |
| 2591 | int ckComFlgs; /* Flags passed to verify_comment() */ |
| 2592 | |
| 2593 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 2594 | url_proxy_options(); |
| 2595 | /* Undocumented. Supported only for backwards |
| 2596 | ** compatibility -------vvvvvvv */ |
| @@ -2655,10 +2663,12 @@ | |
| 2655 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 2656 | useCksum = db_get_boolean("repo-cksum", 1); |
| 2657 | bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0; |
| 2658 | mxSize = db_large_file_size(); |
| 2659 | if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0; |
| 2660 | (void)fossil_text_editor(); |
| 2661 | verify_all_options(); |
| 2662 | |
| 2663 | /* The --no-warnings flag and the --force flag each imply |
| 2664 | ** the --no-verify-comment flag */ |
| @@ -3305,10 +3315,32 @@ | |
| 3305 | vfile_aggregate_checksum_disk(nvid, &cksum2); |
| 3306 | if( blob_compare(&cksum1, &cksum2) ){ |
| 3307 | fossil_fatal("working check-out before and after commit does not match"); |
| 3308 | } |
| 3309 | } |
| 3310 | |
| 3311 | /* Clear the undo/redo stack */ |
| 3312 | undo_reset(); |
| 3313 | |
| 3314 | /* Commit */ |
| 3315 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -2442,11 +2442,11 @@ | |
| 2442 | blob_reset(&txt); |
| 2443 | } |
| 2444 | blob_reset(&html); |
| 2445 | blob_reset(&in); |
| 2446 | return rc; |
| 2447 | } |
| 2448 | |
| 2449 | /* |
| 2450 | ** COMMAND: ci# |
| 2451 | ** COMMAND: commit |
| 2452 | ** |
| @@ -2534,10 +2534,16 @@ | |
| 2534 | ** --proxy PROXY Use PROXY as http proxy during sync operation |
| 2535 | ** --tag TAG-NAME Add TAG-NAME to the check-in. May be repeated. |
| 2536 | ** --trace Debug tracing |
| 2537 | ** --user-override USER Record USER as the login that created the |
| 2538 | ** new check-in, rather that the current user. |
| 2539 | ** --wiki-file FILE Adds FILE's content as a wiki page associated |
| 2540 | ** with this check-in. |
| 2541 | ** --wiki-mimetype TYPE Mimetype for --wiki-file. Default is from the |
| 2542 | ** file extension: .md=markdown, .wiki=fossil, |
| 2543 | ** otherwise plain text. Accepts "markdown", |
| 2544 | ** "wiki", and "plain" as aliases. |
| 2545 | ** |
| 2546 | ** See also: [[branch]], [[changes]], [[update]], [[extras]], [[sync]] |
| 2547 | */ |
| 2548 | void commit_cmd(void){ |
| 2549 | int hasChanges; /* True if unsaved changes exist */ |
| @@ -2587,10 +2593,12 @@ | |
| 2593 | int bIgnoreSkew = 0; /* --ignore-clock-skew flag */ |
| 2594 | int mxSize; |
| 2595 | char *zCurBranch = 0; /* The current branch name of checkout */ |
| 2596 | char *zNewBranch = 0; /* The branch name after update */ |
| 2597 | int ckComFlgs; /* Flags passed to verify_comment() */ |
| 2598 | const char * zWikiFile; /* --wiki-file X */ |
| 2599 | const char * zWikiMime; /* --wiki-mimetype X */ |
| 2600 | |
| 2601 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 2602 | url_proxy_options(); |
| 2603 | /* Undocumented. Supported only for backwards |
| 2604 | ** compatibility -------vvvvvvv */ |
| @@ -2655,10 +2663,12 @@ | |
| 2663 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 2664 | useCksum = db_get_boolean("repo-cksum", 1); |
| 2665 | bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0; |
| 2666 | mxSize = db_large_file_size(); |
| 2667 | if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0; |
| 2668 | zWikiFile = find_option("wiki-file",0,1); |
| 2669 | zWikiMime = find_option("wiki-mimetype",0,1); |
| 2670 | (void)fossil_text_editor(); |
| 2671 | verify_all_options(); |
| 2672 | |
| 2673 | /* The --no-warnings flag and the --force flag each imply |
| 2674 | ** the --no-verify-comment flag */ |
| @@ -3305,10 +3315,32 @@ | |
| 3315 | vfile_aggregate_checksum_disk(nvid, &cksum2); |
| 3316 | if( blob_compare(&cksum1, &cksum2) ){ |
| 3317 | fossil_fatal("working check-out before and after commit does not match"); |
| 3318 | } |
| 3319 | } |
| 3320 | |
| 3321 | if( zWikiFile ){ |
| 3322 | /* Handle --wiki-file and --wiki-mimetype */ |
| 3323 | Blob bWiki = BLOB_INITIALIZER; |
| 3324 | char * zPageName; |
| 3325 | blob_read_from_file(&bWiki, zWikiFile, ExtFILE); |
| 3326 | if( !zWikiMime ){ |
| 3327 | if( 0==sqlite3_strglob("*.md", zWikiFile) ){ |
| 3328 | zWikiMime = "text/x-markdown"; |
| 3329 | }else if( 0==sqlite3_strglob("*.wiki", zWikiFile) ){ |
| 3330 | zWikiMime = "text/x-fossil-wiki"; |
| 3331 | }else{ |
| 3332 | zWikiMime = "text/plain"; |
| 3333 | } |
| 3334 | } |
| 3335 | zWikiMime = wiki_filter_mimetypes(zWikiMime); |
| 3336 | zPageName = mprintf("checkin/%s", zUuid); |
| 3337 | wiki_cmd_commit(zPageName, 0, &bWiki, zWikiMime, 0); |
| 3338 | fossil_print("Added %s (%s)\n", zPageName, zWikiMime); |
| 3339 | blob_reset(&bWiki); |
| 3340 | fossil_free(zPageName); |
| 3341 | } |
| 3342 | |
| 3343 | /* Clear the undo/redo stack */ |
| 3344 | undo_reset(); |
| 3345 | |
| 3346 | /* Commit */ |
| 3347 |