Fossil SCM
Add a "zip" command for generating a ZIP archive of a check-in from the command-line.
Commit
2582ecf2edc2d0d9c5818dc481bc7b330381716d
Parent
0cbc5d295c9911b…
1 file changed
+24
-5
+24
-5
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -378,23 +378,42 @@ | ||
| 378 | 378 | blob_reset(&filename); |
| 379 | 379 | zip_close(pZip); |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /* |
| 383 | -** COMMAND: test-baseline-zip | |
| 383 | +** COMMAND: zip | |
| 384 | +** | |
| 385 | +** Usage: %fossil zip VERSION OUTPUTFILE [--name DIRECTORYNAME] | |
| 384 | 386 | ** |
| 385 | -** Generate a ZIP archive for a specified baseline. | |
| 387 | +** Generate a ZIP archive for a specified version. If the --name option is | |
| 388 | +** used, it argument becomes the name of the top-level directory in the | |
| 389 | +** resulting ZIP archive. If --name is omitted, the top-level directory | |
| 390 | +** named is derived from the project name, the check-in date and time, and | |
| 391 | +** the artifact ID of the check-in. | |
| 386 | 392 | */ |
| 387 | 393 | void baseline_zip_cmd(void){ |
| 388 | 394 | int rid; |
| 389 | 395 | Blob zip; |
| 396 | + const char *zName; | |
| 397 | + zName = find_option("name", 0, 1); | |
| 398 | + db_find_and_open_repository(1); | |
| 390 | 399 | if( g.argc!=4 ){ |
| 391 | - usage("UUID ZIPFILE"); | |
| 400 | + usage("VERSION OUTPUTFILE"); | |
| 392 | 401 | } |
| 393 | - db_must_be_within_tree(); | |
| 394 | 402 | rid = name_to_rid(g.argv[2]); |
| 395 | - zip_of_baseline(rid, &zip, g.argv[2]); | |
| 403 | + if( zName==0 ){ | |
| 404 | + zName = db_text("default-name", | |
| 405 | + "SELECT replace(%Q,' ','_') " | |
| 406 | + " || strftime('_%%Y-%%m-%%d_%%H%%M%%S_', event.mtime) " | |
| 407 | + " || substr(blob.uuid, 1, 10)" | |
| 408 | + " FROM event, blob" | |
| 409 | + " WHERE event.objid=%d" | |
| 410 | + " AND blob.rid=%d", | |
| 411 | + db_get("project-name", "unnamed"), rid, rid | |
| 412 | + ); | |
| 413 | + } | |
| 414 | + zip_of_baseline(rid, &zip, zName); | |
| 396 | 415 | blob_write_to_file(&zip, g.argv[3]); |
| 397 | 416 | } |
| 398 | 417 | |
| 399 | 418 | /* |
| 400 | 419 | ** WEBPAGE: zip |
| 401 | 420 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -378,23 +378,42 @@ | |
| 378 | blob_reset(&filename); |
| 379 | zip_close(pZip); |
| 380 | } |
| 381 | |
| 382 | /* |
| 383 | ** COMMAND: test-baseline-zip |
| 384 | ** |
| 385 | ** Generate a ZIP archive for a specified baseline. |
| 386 | */ |
| 387 | void baseline_zip_cmd(void){ |
| 388 | int rid; |
| 389 | Blob zip; |
| 390 | if( g.argc!=4 ){ |
| 391 | usage("UUID ZIPFILE"); |
| 392 | } |
| 393 | db_must_be_within_tree(); |
| 394 | rid = name_to_rid(g.argv[2]); |
| 395 | zip_of_baseline(rid, &zip, g.argv[2]); |
| 396 | blob_write_to_file(&zip, g.argv[3]); |
| 397 | } |
| 398 | |
| 399 | /* |
| 400 | ** WEBPAGE: zip |
| 401 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -378,23 +378,42 @@ | |
| 378 | blob_reset(&filename); |
| 379 | zip_close(pZip); |
| 380 | } |
| 381 | |
| 382 | /* |
| 383 | ** COMMAND: zip |
| 384 | ** |
| 385 | ** Usage: %fossil zip VERSION OUTPUTFILE [--name DIRECTORYNAME] |
| 386 | ** |
| 387 | ** Generate a ZIP archive for a specified version. If the --name option is |
| 388 | ** used, it argument becomes the name of the top-level directory in the |
| 389 | ** resulting ZIP archive. If --name is omitted, the top-level directory |
| 390 | ** named is derived from the project name, the check-in date and time, and |
| 391 | ** the artifact ID of the check-in. |
| 392 | */ |
| 393 | void baseline_zip_cmd(void){ |
| 394 | int rid; |
| 395 | Blob zip; |
| 396 | const char *zName; |
| 397 | zName = find_option("name", 0, 1); |
| 398 | db_find_and_open_repository(1); |
| 399 | if( g.argc!=4 ){ |
| 400 | usage("VERSION OUTPUTFILE"); |
| 401 | } |
| 402 | rid = name_to_rid(g.argv[2]); |
| 403 | if( zName==0 ){ |
| 404 | zName = db_text("default-name", |
| 405 | "SELECT replace(%Q,' ','_') " |
| 406 | " || strftime('_%%Y-%%m-%%d_%%H%%M%%S_', event.mtime) " |
| 407 | " || substr(blob.uuid, 1, 10)" |
| 408 | " FROM event, blob" |
| 409 | " WHERE event.objid=%d" |
| 410 | " AND blob.rid=%d", |
| 411 | db_get("project-name", "unnamed"), rid, rid |
| 412 | ); |
| 413 | } |
| 414 | zip_of_baseline(rid, &zip, zName); |
| 415 | blob_write_to_file(&zip, g.argv[3]); |
| 416 | } |
| 417 | |
| 418 | /* |
| 419 | ** WEBPAGE: zip |
| 420 |