Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

unit tests for conversion and escaping #44

Closed
bradrydzewski opened this issue May 22, 2019 · 4 comments
Closed

unit tests for conversion and escaping #44

bradrydzewski opened this issue May 22, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@bradrydzewski
Copy link
Member

bradrydzewski commented May 22, 2019

reported errors with the following pipeline:

pipeline:
  inspect:
    image: meltwaterfoundation/drone-git
    commands:
      - git --no-pager diff --name-only $(commit_range.sh) | grep \/

steps to reproduce:

  1. save file to .drone.yml
  2. run drone convert --save
  3. run drone exec

oddly the following steps do not reproduce:

  1. save file to .drone.yml
  2. run drone exec (conversion handled implicitly)
@bradrydzewski bradrydzewski added the bug Something isn't working label May 23, 2019
@bradrydzewski
Copy link
Member Author

bradrydzewski commented May 30, 2019

@jimsheldon I have a local patch that generate the below yaml file. It will quote the string and prevents the extra escape. Can you confirm this doesn't break the command?

kind: pipeline
name: default

platform:
  os: linux
  arch: amd64

steps:
- name: inspect
  pull: default
  image: "alpine:3.8"
  commands:
  - "git --no-pager diff --name-only $(commit_range.sh) | grep /"

@bradrydzewski
Copy link
Member Author

bradrydzewski commented May 30, 2019

Improved escaping now generates the following:

kind: pipeline
name: default

platform:
  os: linux
  arch: amd64

steps:
- name: inspect
  pull: default
  image: alpine:3.8
  commands:
  - ls -la | grep \/

I updated the code to not escape | or > unless these are the starting characters. This should fix the issues with the sample configuration file. However, we should note that escaping may still be imperfect which could impact any yaml file that is generated using drone fmt.

good future reference for escaping:
http://blogs.perl.org/users/tinita/2018/03/strings-in-yaml---to-quote-or-not-to-quote.html

@jimsheldon
Copy link

I can confirm that this pipeline works fine under drone 1.1.0 (simplified the pipeline a bit)

pipeline:
  inspect:
    image: alpine:3.9
    commands:
      - "echo changed/directory | grep /"
    when:
      event: [ pull_request, push ]

Is that what you are asking?

@jimsheldon
Copy link

Verified fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants