Fossil SCM
Add the "fossil git status" command.
Commit
f77ebeeaec04fd6a5418d5db1fcbd6457ea1fae432ee5f90e8df720217bb333f
Parent
9bdda2047fbde3d…
1 file changed
+39
-1
+39
-1
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -1496,10 +1496,41 @@ | ||
| 1496 | 1496 | zPushCmd = mprintf("git push --mirror %s", zPushUrl); |
| 1497 | 1497 | fossil_system(zPushCmd); |
| 1498 | 1498 | fossil_free(zPushCmd); |
| 1499 | 1499 | } |
| 1500 | 1500 | } |
| 1501 | + | |
| 1502 | +/* | |
| 1503 | +** Implementation of the "fossil git status" command. | |
| 1504 | +** | |
| 1505 | +** Show the status of a "git export". | |
| 1506 | +*/ | |
| 1507 | +void gitmirror_status_command(void){ | |
| 1508 | + char *zMirror; | |
| 1509 | + char *z; | |
| 1510 | + db_find_and_open_repository(0, 0); | |
| 1511 | + verify_all_options(); | |
| 1512 | + zMirror = db_get("last-git-export-repo", 0); | |
| 1513 | + if( zMirror==0 ){ | |
| 1514 | + fossil_print("Git mirror: none\n"); | |
| 1515 | + return; | |
| 1516 | + } | |
| 1517 | + fossil_print("Git mirror: %s\n", zMirror); | |
| 1518 | + db_multi_exec("ATTACH '%q/.mirror_state/db' AS mirror;", zMirror); | |
| 1519 | + z = db_text(0, "SELECT datetime(value) FROM mconfig WHERE key='start'"); | |
| 1520 | + if( z ){ | |
| 1521 | + fossil_print("Last export: %s\n", z); | |
| 1522 | + } | |
| 1523 | + z = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'"); | |
| 1524 | + if( z==0 ){ | |
| 1525 | + fossil_print("Autopush: off\n"); | |
| 1526 | + }else{ | |
| 1527 | + UrlData url; | |
| 1528 | + url_parse_local(z, 0, &url); | |
| 1529 | + fossil_print("Autopush: %s\n", url.canonical); | |
| 1530 | + } | |
| 1531 | +} | |
| 1501 | 1532 | |
| 1502 | 1533 | /* |
| 1503 | 1534 | ** COMMAND: git |
| 1504 | 1535 | ** |
| 1505 | 1536 | ** Usage: %fossil git SUBCOMMAND |
| @@ -1539,10 +1570,14 @@ | ||
| 1539 | 1570 | ** --verbose|-v More output. |
| 1540 | 1571 | ** |
| 1541 | 1572 | ** fossil git import MIRROR |
| 1542 | 1573 | ** |
| 1543 | 1574 | ** TBD... |
| 1575 | +** | |
| 1576 | +** fossil git status | |
| 1577 | +** | |
| 1578 | +** Show the status of the current Git mirror, if there is one. | |
| 1544 | 1579 | */ |
| 1545 | 1580 | void gitmirror_command(void){ |
| 1546 | 1581 | char *zCmd; |
| 1547 | 1582 | int nCmd; |
| 1548 | 1583 | if( g.argc<3 ){ |
| @@ -1554,11 +1589,14 @@ | ||
| 1554 | 1589 | gitmirror_export_command(); |
| 1555 | 1590 | }else |
| 1556 | 1591 | if( nCmd>2 && strncmp(zCmd,"import",nCmd)==0 ){ |
| 1557 | 1592 | fossil_fatal("not yet implemented - check back later"); |
| 1558 | 1593 | }else |
| 1594 | + if( nCmd>2 && strncmp(zCmd,"status",nCmd)==0 ){ | |
| 1595 | + gitmirror_status_command(); | |
| 1596 | + }else | |
| 1559 | 1597 | { |
| 1560 | 1598 | fossil_fatal("unknown subcommand \"%s\": should be one of " |
| 1561 | - "\"export\", \"import\"", | |
| 1599 | + "\"export\", \"import\", \"status\"", | |
| 1562 | 1600 | zCmd); |
| 1563 | 1601 | } |
| 1564 | 1602 | } |
| 1565 | 1603 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1496,10 +1496,41 @@ | |
| 1496 | zPushCmd = mprintf("git push --mirror %s", zPushUrl); |
| 1497 | fossil_system(zPushCmd); |
| 1498 | fossil_free(zPushCmd); |
| 1499 | } |
| 1500 | } |
| 1501 | |
| 1502 | /* |
| 1503 | ** COMMAND: git |
| 1504 | ** |
| 1505 | ** Usage: %fossil git SUBCOMMAND |
| @@ -1539,10 +1570,14 @@ | |
| 1539 | ** --verbose|-v More output. |
| 1540 | ** |
| 1541 | ** fossil git import MIRROR |
| 1542 | ** |
| 1543 | ** TBD... |
| 1544 | */ |
| 1545 | void gitmirror_command(void){ |
| 1546 | char *zCmd; |
| 1547 | int nCmd; |
| 1548 | if( g.argc<3 ){ |
| @@ -1554,11 +1589,14 @@ | |
| 1554 | gitmirror_export_command(); |
| 1555 | }else |
| 1556 | if( nCmd>2 && strncmp(zCmd,"import",nCmd)==0 ){ |
| 1557 | fossil_fatal("not yet implemented - check back later"); |
| 1558 | }else |
| 1559 | { |
| 1560 | fossil_fatal("unknown subcommand \"%s\": should be one of " |
| 1561 | "\"export\", \"import\"", |
| 1562 | zCmd); |
| 1563 | } |
| 1564 | } |
| 1565 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1496,10 +1496,41 @@ | |
| 1496 | zPushCmd = mprintf("git push --mirror %s", zPushUrl); |
| 1497 | fossil_system(zPushCmd); |
| 1498 | fossil_free(zPushCmd); |
| 1499 | } |
| 1500 | } |
| 1501 | |
| 1502 | /* |
| 1503 | ** Implementation of the "fossil git status" command. |
| 1504 | ** |
| 1505 | ** Show the status of a "git export". |
| 1506 | */ |
| 1507 | void gitmirror_status_command(void){ |
| 1508 | char *zMirror; |
| 1509 | char *z; |
| 1510 | db_find_and_open_repository(0, 0); |
| 1511 | verify_all_options(); |
| 1512 | zMirror = db_get("last-git-export-repo", 0); |
| 1513 | if( zMirror==0 ){ |
| 1514 | fossil_print("Git mirror: none\n"); |
| 1515 | return; |
| 1516 | } |
| 1517 | fossil_print("Git mirror: %s\n", zMirror); |
| 1518 | db_multi_exec("ATTACH '%q/.mirror_state/db' AS mirror;", zMirror); |
| 1519 | z = db_text(0, "SELECT datetime(value) FROM mconfig WHERE key='start'"); |
| 1520 | if( z ){ |
| 1521 | fossil_print("Last export: %s\n", z); |
| 1522 | } |
| 1523 | z = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'"); |
| 1524 | if( z==0 ){ |
| 1525 | fossil_print("Autopush: off\n"); |
| 1526 | }else{ |
| 1527 | UrlData url; |
| 1528 | url_parse_local(z, 0, &url); |
| 1529 | fossil_print("Autopush: %s\n", url.canonical); |
| 1530 | } |
| 1531 | } |
| 1532 | |
| 1533 | /* |
| 1534 | ** COMMAND: git |
| 1535 | ** |
| 1536 | ** Usage: %fossil git SUBCOMMAND |
| @@ -1539,10 +1570,14 @@ | |
| 1570 | ** --verbose|-v More output. |
| 1571 | ** |
| 1572 | ** fossil git import MIRROR |
| 1573 | ** |
| 1574 | ** TBD... |
| 1575 | ** |
| 1576 | ** fossil git status |
| 1577 | ** |
| 1578 | ** Show the status of the current Git mirror, if there is one. |
| 1579 | */ |
| 1580 | void gitmirror_command(void){ |
| 1581 | char *zCmd; |
| 1582 | int nCmd; |
| 1583 | if( g.argc<3 ){ |
| @@ -1554,11 +1589,14 @@ | |
| 1589 | gitmirror_export_command(); |
| 1590 | }else |
| 1591 | if( nCmd>2 && strncmp(zCmd,"import",nCmd)==0 ){ |
| 1592 | fossil_fatal("not yet implemented - check back later"); |
| 1593 | }else |
| 1594 | if( nCmd>2 && strncmp(zCmd,"status",nCmd)==0 ){ |
| 1595 | gitmirror_status_command(); |
| 1596 | }else |
| 1597 | { |
| 1598 | fossil_fatal("unknown subcommand \"%s\": should be one of " |
| 1599 | "\"export\", \"import\", \"status\"", |
| 1600 | zCmd); |
| 1601 | } |
| 1602 | } |
| 1603 |