salt icon indicating copy to clipboard operation
salt copied to clipboard

svn.export halts if file exists

Open jessecollier opened this issue 12 years ago • 4 comments

I'm getting hung up on https://github.com/saltstack/salt/blob/develop/salt/states/svn.py#L200-L204

Essentially I want to grab a file from svn no matter what, even if the file/dir exists. I thought using force would allow me to do this, but it looks like I would have to use a cmd.run to remove the file so this doesn't fail.

Is this a bug? Or is my use case just different than intended? I'd like to be able to override this check some how. What do you think?

jessecollier avatar May 28 '14 21:05 jessecollier

That does seem like a bug to me. I would probably want it to compare to the version in SVN to make sure I have the most up-to-date version.

basepi avatar May 28 '14 22:05 basepi

Well, export should always give you the latest version it has. I think just having "overwrite" flag would be safe and explicit.

In the interim I am using this macro to get around this.

{% macro svn_export(source,dest) -%}
{{ dest }}:
  cmd.run:
    - name: rm {{ dest }}
    - onlyif: |
        [ -f {{ dest }} ]
  svn.export:
    - name: svn+ssh://localhost/{{ source }}
    - target: {{ dest }}
    - force: True
    - require:
        - cmd: {{ dest }}
{% endmacro -%}

jessecollier avatar May 28 '14 22:05 jessecollier

So I've submitted a PR for what makes sense to me. Please comment :)

jessecollier avatar May 28 '14 23:05 jessecollier

Awesome, looks great!

basepi avatar May 29 '14 16:05 basepi