diff --git a/.travis.yml b/.travis.yml index 7d048a7..4b0078e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,4 +20,6 @@ matrix: - pytest --cov - coveralls +install: pip install -e .[tests] + script: pytest -v diff --git a/README.md b/README.md index 4bd6162..0decfaf 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,11 @@ python -m pip install -e . I didn't know of any other easy ways to do these Git tasks: * `gitbranch` Tells of any non-master branches under directory ~/code -* `git_filemode_windows` Sets all git repos to don't care permissions under directory ~/code * `gitemail` list all contributor email addresses. Optionally, amend email addresses for prior Git commits ### Sync large number of git repos -These assume numerous subdirectories under `~/code` or `c:\code`. +These assume numerous subdirectories under `~/code` or `c:\code`. They work very quickly for large numbers (100+) repos. @@ -67,7 +66,7 @@ You can place an empty file `.nogit` in a subdirectory to skip it. #### [optional] speedup with https pull For public repos, to make the Git remote checking go at least twice as fast, and significantly reduce the computational burden when SSH is used for `git push` (as is recommended), consider the "pushInsteadOf" global Git config. -To do this, when cloning a public repo (including ones you're a collaborator on), use `git clone https://`. +To do this, when cloning a public repo (including ones you're a collaborator on), use `git clone https://`. This global SSH push config one-time does SSH push for HTTPS-cloned repos: ```sh git config --global url."ssh://github.com/".pushInsteadOf https://github.com/ diff --git a/git_filemode_windows.py b/git_filemode_windows.py deleted file mode 100755 index d4a9ef3..0000000 --- a/git_filemode_windows.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -""" -sets core.fileMode=false for git repos -mostly for Windows, particularly Cygwin -""" -from pathlib import Path -from subprocess import call -from argparse import ArgumentParser - - -def main(): - p = ArgumentParser() - p.add_argument('codepath', help='path to code root', nargs='?', default='~/code') - p = p.parse_args() - - rdir = Path(p.codepath).expanduser() - - dlist = [x for x in rdir.iterdir() if x.is_dir()] - - print('setting fileMode=false for', len(dlist), 'directories under', rdir) - - for d in dlist: - call(['git', 'config', 'core.filemode', 'false'], cwd=d) - - -if __name__ == '__main__': - main() diff --git a/gitutils/branch.py b/gitutils/branch.py index 5c54655..43ac22b 100644 --- a/gitutils/branch.py +++ b/gitutils/branch.py @@ -6,13 +6,8 @@ from pathlib import Path import asyncio import logging -import shutil -from .git import baddir - -GITEXE = shutil.which('git') -if not GITEXE: - raise FileNotFoundError('Could not find executable for Git') +from .git import baddir, GITEXE CMD = [GITEXE, 'rev-parse', '--abbrev-ref', 'HEAD'] diff --git a/gitutils/git.py b/gitutils/git.py index 8661ac5..75e9dc1 100644 --- a/gitutils/git.py +++ b/gitutils/git.py @@ -21,10 +21,10 @@ """ replaced by git status --porcelain: - ['git','ls-files','-o','-d','--exclude-standard']): # check for uncommitted files - ['git','--no-pager','diff','HEAD'], # check for uncommitted work + git ls-files -o -d --exclude-standard: # check for uncommitted files + git --no-pager diff HEAD , # check for uncommitted work -DOES NOT WORK ['git','log','--branches','--not','--remotes'], # check for uncommitted branches +DOES NOT WORK git log --branches --not --remotes # check for uncommitted branches """ @@ -94,7 +94,7 @@ def listchanged(path: Path) -> List[str]: changes : list of str filenames changed in this Git repo """ - ret = subprocess.check_output(['git', 'ls-files', '--modified'], + ret = subprocess.check_output([GITEXE, 'ls-files', '--modified'], universal_newlines=True, cwd=path)