diff options
author | Teddy Wing | 2019-06-02 04:56:49 +0200 |
---|---|---|
committer | Teddy Wing | 2019-06-02 04:56:49 +0200 |
commit | b49f7844e09a29b6b2a5e6ef71c6c17b4c7ed9fc (patch) | |
tree | 6a430122ba52aa82cbe8e7807fecad201bdf78bf /git-changed-files | |
parent | a98dccc55500ba55b90d17092e51c308d2febffc (diff) | |
download | code-review-b49f7844e09a29b6b2a5e6ef71c6c17b4c7ed9fc.tar.bz2 |
git-changed-files: Get an absolute path to the files (WIP)
A couple methods to get the absolute path to the changed files. This
allows the output to be used to operate on changed files even if the
current directory is not the repo root. Otherwise, all files are listed
relative to the repository root.
Diffstat (limited to 'git-changed-files')
-rwxr-xr-x | git-changed-files | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/git-changed-files b/git-changed-files index 30a9c5c..615111f 100755 --- a/git-changed-files +++ b/git-changed-files @@ -1,3 +1,10 @@ #!/bin/sh git diff --name-only "$@" + +# Use absolute path in case the PWD is not the Git root +sed "s,/^,$(git rev-parse --show-toplevel)," +$(git rev-parse --show-toplevel) +awk '{ print "[CMD]" $0 }' + +git changed-files master.. | grep '_test\.go$' | awk -v git_root=$(git rev-parse --show-toplevel) '{ print git_root "/" $0 }' |