Skip to content

Commit 385d723

Browse files
committed
Added option to ignore configured exclude paths
1 parent c93faa7 commit 385d723

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

gitall/gitall.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def __init__(self):
2121
self._sort_status = True
2222
self._colored = True
2323

24-
def load(self):
24+
def load(self, no_excludes: bool = False):
2525
config_home = os.path.expanduser("~/" + self._configname)
2626
if os.path.exists(config_home):
27-
self._load_config(config_home)
27+
self._load_config(config_home, no_excludes)
2828
config_local = "./" + self._configname
2929
if os.path.exists(config_local):
30-
self._load_config(config_local)
30+
self._load_config(config_local, no_excludes)
3131

32-
def _load_config(self, configfile):
32+
def _load_config(self, configfile, no_excludes: bool):
3333
config = configparser.ConfigParser()
3434
config.read(configfile)
3535
if "gitall" in config:
@@ -44,9 +44,9 @@ def _load_config(self, configfile):
4444
if sort != "":
4545
self._sort = (sort != "no")
4646
self._sort_status = (sort == "status")
47-
# Not a very safe way of splitting path lists, but better than nothing and good enough for me ..
48-
excluded = [ e.strip() for e in excluded.split("\n") ]
49-
self.exclude(excluded)
47+
if not no_excludes:
48+
excluded = [ e.strip() for e in excluded.split("\n") ]
49+
self.exclude(excluded)
5050

5151
def exclude(self, excluded_dirs: []):
5252
for d in excluded_dirs:
@@ -218,14 +218,17 @@ def main():
218218
"Can be specified multiple times.")
219219
parser.add_argument("-e", "--exclude", action="append", type=str, default=[],
220220
help="Specify directories to exclude from the search. Can be specified multiple times.")
221+
parser.add_argument("-x", "--ignore-config-excludes", action=argparse.BooleanOptionalAction, default=False,
222+
dest = "ignore_excludes",
223+
help="Ignore exclude paths from config files, ie., only use exclude paths from command line.")
221224
parser.add_argument("-u", "--subrepos", action=argparse.BooleanOptionalAction, default=None,
222-
help="Search for git repositories within git repositories.")
225+
help="Search for git repositories within git repositories (default: False).")
223226
parser.add_argument("-s", "--sort", choices=["no", "path", "status"], default=None,
224-
help="Sort repositories based on status, list modified repos last.")
227+
help="Sort repositories based on status, list modified repos last (default: status).")
225228
parser.add_argument("-t", "--status", action=argparse.BooleanOptionalAction, default=None,
226229
help="Check and print the status of the repositories (default: True).")
227-
parser.add_argument("-x", "--abort", action=argparse.BooleanOptionalAction, default=False, dest="abort_on_error",
228-
help="Abort on first git command error.")
230+
parser.add_argument("-a", "--abort", action=argparse.BooleanOptionalAction, default=False, dest="abort_on_error",
231+
help="Abort on first git command error (default: False).")
229232
parser.add_argument("command", metavar="command", type=str, nargs=argparse.REMAINDER)
230233

231234
args = parser.parse_args()
@@ -238,7 +241,7 @@ def main():
238241
# Setup configuration
239242
config = Config()
240243
# Load config file
241-
config.load()
244+
config.load(args.ignore_excludes)
242245
# Override config with commandline args
243246
config.exclude(args.exclude)
244247
if args.sort is not None:

0 commit comments

Comments
 (0)