@@ -1320,3 +1320,124 @@ def checkout(
1320
1320
["checkout" , * local_flags , * (["--" , * pathspec ] if len (pathspec ) else [])],
1321
1321
check_returncode = False ,
1322
1322
)
1323
+
1324
+ def status (
1325
+ self ,
1326
+ verbose : Optional [bool ] = None ,
1327
+ long : Optional [bool ] = None ,
1328
+ short : Optional [bool ] = None ,
1329
+ branch : Optional [bool ] = None ,
1330
+ z : Optional [bool ] = None ,
1331
+ column : Optional [Union [bool , str ]] = None ,
1332
+ no_column : Optional [bool ] = None ,
1333
+ ahead_behind : Optional [bool ] = None ,
1334
+ no_ahead_behind : Optional [bool ] = None ,
1335
+ renames : Optional [bool ] = None ,
1336
+ no_renames : Optional [bool ] = None ,
1337
+ find_renames : Optional [Union [bool , str ]] = None ,
1338
+ porcelain : Optional [Union [bool , str ]] = None ,
1339
+ untracked_files : Optional [Literal ["no" , "normal" , "all" ]] = None ,
1340
+ ignored : Optional [Literal ["traditional" , "no" , "matching" ]] = None ,
1341
+ ignored_submodules : Optional [Literal ["untracked" , "dirty" , "all" ]] = None ,
1342
+ pathspec : Optional [Union [StrOrBytesPath , list [StrOrBytesPath ]]] = None ,
1343
+ ** kwargs ,
1344
+ ):
1345
+ """Status of working tree. Wraps
1346
+ `git status <https://git-scm.com/docs/git-status>`_.
1347
+
1348
+ `git ls-files` has similar params (e.g. `z`)
1349
+
1350
+ Parameters
1351
+ ----------
1352
+ verbose : bool
1353
+ long : bool
1354
+ short : bool
1355
+ branch : bool
1356
+ z : bool
1357
+ column : bool
1358
+ no_column : bool
1359
+ ahead_behind : bool
1360
+ no_ahead_behind : bool
1361
+ find_renames : bool
1362
+ no_find_renames : bool
1363
+ porcelain : str, bool
1364
+ untracked_files : "no", "normal", "all"
1365
+ ignored : "traditional", "no", "matching"
1366
+ ignored_submodules : "untracked", "dirty", "all"
1367
+ pathspec : :attr:`libvcs.cmd.types.StrOrBytesPath` or list
1368
+ :attr:`libvcs.cmd.types.StrOrBytesPath`
1369
+
1370
+ Examples
1371
+ --------
1372
+ >>> git = Git(dir=git_local_clone.dir)
1373
+
1374
+ >>> git.status()
1375
+ "On branch master..."
1376
+
1377
+ >>> pathlib.Path(git_local_clone.dir / 'new_file.txt').touch()
1378
+
1379
+ >>> git.status(porcelain=True)
1380
+ '?? new_file.txt'
1381
+
1382
+ >>> git.status(porcelain='1')
1383
+ '?? new_file.txt'
1384
+
1385
+ >>> git.status(porcelain='2')
1386
+ '? new_file.txt'
1387
+ """
1388
+ local_flags : list [str ] = []
1389
+
1390
+ if verbose is True :
1391
+ local_flags .append ("--verbose" )
1392
+
1393
+ if long is True :
1394
+ local_flags .append ("--long" )
1395
+
1396
+ if short is True :
1397
+ local_flags .append ("--short" )
1398
+
1399
+ if branch is True :
1400
+ local_flags .append ("--branch" )
1401
+
1402
+ if z is True :
1403
+ local_flags .append ("--z" )
1404
+
1405
+ if untracked_files is not None and isinstance (untracked_files , str ):
1406
+ local_flags .append (f"--untracked-files={ untracked_files } " )
1407
+
1408
+ if ignored is not None and isinstance (column , str ):
1409
+ local_flags .append (f"--ignored={ ignored } " )
1410
+
1411
+ if ignored_submodules is not None :
1412
+ if isinstance (column , str ):
1413
+ local_flags .append (f"--ignored-submodules={ ignored_submodules } " )
1414
+ else :
1415
+ local_flags .append ("--ignored-submodules" )
1416
+
1417
+ if column is not None :
1418
+ if isinstance (column , str ):
1419
+ local_flags .append (f"--column={ column } " )
1420
+ else :
1421
+ local_flags .append ("--column" )
1422
+ elif no_column is not None :
1423
+ local_flags .append ("--no-column" )
1424
+
1425
+ if porcelain is not None :
1426
+ if isinstance (porcelain , str ):
1427
+ local_flags .append (f"--porcelain={ porcelain } " )
1428
+ else :
1429
+ local_flags .append ("--porcelain" )
1430
+
1431
+ if find_renames is True :
1432
+ local_flags .append (f"--find-renames={ find_renames } " )
1433
+
1434
+ if pathspec is not None :
1435
+ if not isinstance (pathspec , list ):
1436
+ pathspec = [pathspec ]
1437
+ else :
1438
+ pathspec = []
1439
+
1440
+ return self .run (
1441
+ ["status" , * local_flags , * (["--" , * pathspec ] if len (pathspec ) else [])],
1442
+ check_returncode = False ,
1443
+ )
0 commit comments