I'd like to get the list of changed files and only scan them. Ideally it would be all files in the PR but it could be compared to a specific branch (e.g. master).
I really want to isolate the case of an incremental build over a full build because the difference is an order of magnitude in seconds, and this isn't a big repository.
Note, this is in a pipe, not a pipeline. (Well, of course the pipe is called from a pipeline, but you know what I mean).
if I do a git diff HEAD..master (or origin/master) it doesn't work.
If I look in .git/refs/heads, I don't have any other reference than the current branch.
if I do a git fetch:
+ git fetch
fatal: unable to access 'http://bitbucket.org/mvcode/mv-devops/': Failed to connect to localhost port 29418: Connection refused
If I set the ssh or http origin then I get errors. (have to re-run these to get the errors.)
ssh:
+ git remote set-url origin git@bitbucket.org:mvcode/mv-devops.git
+ git ls-remote
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
http:
+ git remote set-url origin http://bitbucket.org/mvcode/mv-devops
+ git ls-remote
fatal: unable to access 'http://bitbucket.org/mvcode/mv-devops/': Failed to connect to localhost port 29418: Connection refused
(that host mapping to localhost is cute, it would be nice if it did the right thing in pipes and used the host.docker.internal instead).
If I set it to the pipe host.docker.internal:29418 value I get errors.
+ git remote set-url origin http://host.docker.internal:29418
+ git ls-remote
fatal: unable to access 'http://host.docker.internal:29418/': The requested URL returned error: 502
If I try to use the API to do a diffstat, as I've seen elsewhere, I get you must be admin or have write access, which A) doesn't make sense, I'm reading, B) I _do_ have that access (the pipe may not).
++ curl -s --proxy http://host.docker.internal:29418 --request GET http://api.bitbucket.org/2.0/repositories/mvcode/mv-devops/diffstat/f7f6a6bca8181653f3e4208fbd3ac6874942d36d
Access denied. You must have write or admin access.
So it looks like I can probably auth my way in, but I feel that the files that changed should be intrinsic knowledge to a PR. It should be easily available and there shouldn't be a need for auth as it's a read only operation on state that you have an even more complete access to. Ideally this would be available without an API or git operation, like in a well-known location.
# save just in case
BACKUP_PROXY=$(git config "http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy")
# replace
git config "http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy" http://host.docker.internal:29418
# fetch
git fetch origin "${DEFAULT_BRANCH}"
mapfile -t RAW_FILE_ARRAY < <(git -C "${GITHUB_WORKSPACE}" diff --name-only "FETCH_HEAD..${GITHUB_SHA}" --diff-filter=d 2>&1)
# restore just in case
git config "http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy" "$BACKUP_PROXY"
This feels like a bug.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.