Fossil SCM

Add the "fossil git status" command.

drh 2019-04-22 13:54 trunk
Commit f77ebeeaec04fd6a5418d5db1fcbd6457ea1fae432ee5f90e8df720217bb333f
1 file changed +39 -1
+39 -1
--- src/export.c
+++ src/export.c
@@ -1496,10 +1496,41 @@
14961496
zPushCmd = mprintf("git push --mirror %s", zPushUrl);
14971497
fossil_system(zPushCmd);
14981498
fossil_free(zPushCmd);
14991499
}
15001500
}
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
+}
15011532
15021533
/*
15031534
** COMMAND: git
15041535
**
15051536
** Usage: %fossil git SUBCOMMAND
@@ -1539,10 +1570,14 @@
15391570
** --verbose|-v More output.
15401571
**
15411572
** fossil git import MIRROR
15421573
**
15431574
** TBD...
1575
+**
1576
+** fossil git status
1577
+**
1578
+** Show the status of the current Git mirror, if there is one.
15441579
*/
15451580
void gitmirror_command(void){
15461581
char *zCmd;
15471582
int nCmd;
15481583
if( g.argc<3 ){
@@ -1554,11 +1589,14 @@
15541589
gitmirror_export_command();
15551590
}else
15561591
if( nCmd>2 && strncmp(zCmd,"import",nCmd)==0 ){
15571592
fossil_fatal("not yet implemented - check back later");
15581593
}else
1594
+ if( nCmd>2 && strncmp(zCmd,"status",nCmd)==0 ){
1595
+ gitmirror_status_command();
1596
+ }else
15591597
{
15601598
fossil_fatal("unknown subcommand \"%s\": should be one of "
1561
- "\"export\", \"import\"",
1599
+ "\"export\", \"import\", \"status\"",
15621600
zCmd);
15631601
}
15641602
}
15651603
--- 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

Keyboard Shortcuts

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