telia-oss / github-pr-resource

Github pull request resource for Concourse
MIT License
182 stars 5 forks source link

get list_changed_files does not appear in .git/resources/ #272

Open djcal460 opened 2 years ago

djcal460 commented 2 years ago

When get my pr resource and set the params for list_changed_files: true this does not create a directory as stated in the documentation. For example,

  - get: git-pr
    trigger: true
    version: every
    params:
      list_changed_files: true

After I get the pr resource and put it into pending, I then pass the resource to a task and run a script:

  - task: find_input
    input_mapping:
      source-repo: git-pr
    config:
       ...
      inputs:
        - name: source-repo
      outputs:
        - name: dest-repo
      run:
        path: sh
        args:
          - -exc
          - |
            ls -la source-repo/.git/resource/  >> dest-repo/new_output.txt

Later in the output task, I cat dest-repo/new_output.txt. I do not see .git/resources/changed_files listed. Only the following:

Nov 17 18:41 . Nov 17 18:41 .. Nov 17 18:41 author Nov 17 18:41 author_email Nov 17 18:41 base_name Nov 17 18:41 base_sha Nov 17 18:41 head_name Nov 17 18:41 head_sha Nov 17 18:41 message Nov 17 18:41 metadata.json Nov 17 18:41 pr Nov 17 18:41 state Nov 17 18:41 title Nov 17 18:41 url Nov 17 18:41 version.json

Is this a bug or am I doing anything wrong? Thanks in advance!

EdgeJ commented 2 years ago

@djcal460 I had this same issue and took a while to figure out what was going on. The issue here is the implicit get done when you put the resource to set the status wipes out the previous metadata files for subsequent tasks. What I ended up doing in a similar situation was something like this:

- get: ci
  trigger: true
  version: every

- put: ci
  params:
    path: ci
    context: validation
    status: pending
  get_params:
    list_changed_files: true

- task: foo
...

Using list_changed_files in the put step instead of the get seemed to solve this problem.

bgandon commented 4 months ago

Glad you found an answer to your issue!

But this would also need an update in the docs, don't you think?

Recent news is that the Cloud Foundry community is now maintaining a fork of this resource at cloudfoundry-community/github-pr-resource.

On our Concourse installation at Gstack, that one is working fine. Could you give a try and submit a PR to the docs there?

_(the new resource is a drop-in replacement; you only have to switch telia-ossto cfcommunity in in the resource_types: declaration, i.e. specify repository: cfcommunity/github-pr-resource)_