We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
build.py corrupts yaml
## Description
I ran into an issue with entries in values.yaml file after using the build.py script. My `extraVolume` entries were corrupted.

## Reproduction

```yaml
# create this file and name it values.yaml
root-1:
  # offset=2 will indent the dash 2 spaces (default: 2)
  # sequence=4 will indent indent-status-2 4 spaces and ignore what offset is used (default: 2)
  - indent-status-1: ok
    indent-status-2: bad after ./test.py runs
root-2:
  # mapping=2 will indent the following entry 2 spaces (default: 2)
  name: old-name
```

```python
# create this runnable.py file, and run it
import os
from ruamel.yaml import YAML

def main():
    yaml = YAML()
    yaml.indent(mapping=2, offset=2, sequence=4)

    with open('values.yaml') as f:
        values = yaml.load(f)

    values['root-2'].update({'name': 'new-name'})

    with open('values.yaml', 'w') as f:
        yaml.dump(values, f)


main()
```

## Corrupt output

#### Look at `indent-status-2`, it has a indentation causing the yaml to become corrupt.
```yaml
# create this file and name it values.yaml
root-1:
  # offset=2 will indent the dash 2 spaces (default: 2)
  # sequence=4 will indent indent-status-2 4 spaces and ignore what offset is used (default: 2)
  - indent-status-1: ok
  indent-status-2: bad after ./test.py runs
root-2:
  # mapping=2 will indent the following entry 2 spaces (default: 2)
  name: new-name
```
build.py corrupts yaml
## Description
I ran into an issue with entries in values.yaml file after using the build.py script. My `extraVolume` entries were corrupted.

## Reproduction

```yaml
# create this file and name it values.yaml
root-1:
  # offset=2 will indent the dash 2 spaces (default: 2)
  # sequence=4 will indent indent-status-2 4 spaces and ignore what offset is used (default: 2)
  - indent-status-1: ok
    indent-status-2: bad after ./test.py runs
root-2:
  # mapping=2 will indent the following entry 2 spaces (default: 2)
  name: old-name
```

```python
# create this runnable.py file, and run it
import os
from ruamel.yaml import YAML

def main():
    yaml = YAML()
    yaml.indent(mapping=2, offset=2, sequence=4)

    with open('values.yaml') as f:
        values = yaml.load(f)

    values['root-2'].update({'name': 'new-name'})

    with open('values.yaml', 'w') as f:
        yaml.dump(values, f)


main()
```

## Corrupt output

#### Look at `indent-status-2`, it has a indentation causing the yaml to become corrupt.
```yaml
# create this file and name it values.yaml
root-1:
  # offset=2 will indent the dash 2 spaces (default: 2)
  # sequence=4 will indent indent-status-2 4 spaces and ignore what offset is used (default: 2)
  - indent-status-1: ok
  indent-status-2: bad after ./test.py runs
root-2:
  # mapping=2 will indent the following entry 2 spaces (default: 2)
  name: new-name
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `build.py`
Content:
```
1 #!/usr/bin/env python3
2 import argparse
3 import os
4 import subprocess
5 import shutil
6 from tempfile import TemporaryDirectory
7 
8 from ruamel.yaml import YAML
9 
10 # use safe roundtrip yaml loader
11 yaml = YAML(typ='rt')
12 yaml.indent(offset=2)
13 
14 def last_modified_commit(*paths, **kwargs):
15     return subprocess.check_output([
16         'git',
17         'log',
18         '-n', '1',
19         '--pretty=format:%h',
20         *paths
21     ], **kwargs).decode('utf-8')
22 
23 def last_modified_date(*paths, **kwargs):
24     return subprocess.check_output([
25         'git',
26         'log',
27         '-n', '1',
28         '--pretty=format:%cd',
29         '--date=iso',
30         *paths
31     ], **kwargs).decode('utf-8')
32 
33 def path_touched(*paths, commit_range):
34     return subprocess.check_output([
35         'git', 'diff', '--name-only', commit_range, *paths
36     ]).decode('utf-8').strip() != ''
37 
38 
39 def render_build_args(options, ns):
40     """Get docker build args dict, rendering any templated args."""
41     build_args = options.get('buildArgs', {})
42     for key, value in build_args.items():
43         build_args[key] = value.format(**ns)
44     return build_args
45 
46 def build_image(image_path, image_spec, build_args):
47     cmd = ['docker', 'build', '-t', image_spec, image_path]
48 
49     for k, v in build_args.items():
50         cmd += ['--build-arg', '{}={}'.format(k, v)]
51     subprocess.check_call(cmd)
52 
53 def build_images(prefix, images, tag=None, commit_range=None, push=False):
54     value_modifications = {}
55     for name, options in images.items():
56         image_path = os.path.join('images', name)
57         paths = options.get('paths', []) + [image_path]
58         last_commit = last_modified_commit(*paths)
59         if tag is None:
60             tag = last_commit
61         image_name = prefix + name
62         image_spec = '{}:{}'.format(image_name, tag)
63         value_modifications[options['valuesPath']] = {
64             'name': image_name,
65             'tag': tag
66         }
67 
68         if commit_range and not path_touched(*paths, commit_range=commit_range):
69             print(f"Skipping {name}, not touched in {commit_range}")
70             continue
71 
72         template_namespace = {
73             'LAST_COMMIT': last_commit,
74             'TAG': tag,
75         }
76 
77         build_args = render_build_args(options, template_namespace)
78         build_image(image_path, image_spec, build_args)
79 
80         if push:
81             subprocess.check_call([
82                 'docker', 'push', image_spec
83             ])
84     return value_modifications
85 
86 def build_values(name, values_mods):
87     """Update name/values.yaml with modifications"""
88 
89     values_file = os.path.join(name, 'values.yaml')
90 
91     with open(values_file) as f:
92         values = yaml.load(f)
93 
94     for key, value in values_mods.items():
95         parts = key.split('.')
96         mod_obj = values
97         for p in parts:
98             mod_obj = mod_obj[p]
99         mod_obj.update(value)
100 
101 
102     with open(values_file, 'w') as f:
103         yaml.dump(values, f)
104 
105 
106 def build_chart(name, version=None, paths=None):
107     """Update chart with specified version or last-modified commit in path(s)"""
108     chart_file = os.path.join(name, 'Chart.yaml')
109     with open(chart_file) as f:
110         chart = yaml.load(f)
111 
112     if version is None:
113         if paths is None:
114             paths = ['.']
115         commit = last_modified_commit(*paths)
116         version = chart['version'].split('-')[0] + '-' + commit
117 
118     chart['version'] = version
119 
120     with open(chart_file, 'w') as f:
121         yaml.dump(chart, f)
122 
123 
124 def publish_pages(name, paths, git_repo, published_repo):
125     """publish helm chart index to github pages"""
126     version = last_modified_commit(*paths)
127     checkout_dir = '{}-{}'.format(name, version)
128     subprocess.check_call([
129         'git', 'clone', '--no-checkout',
130         'git@github.com:{}'.format(git_repo), checkout_dir],
131     )
132     subprocess.check_call(['git', 'checkout', 'gh-pages'], cwd=checkout_dir)
133 
134     # package the latest version into a temporary directory
135     # and run helm repo index with --merge to update index.yaml
136     # without refreshing all of the timestamps
137     with TemporaryDirectory() as td:
138         subprocess.check_call([
139             'helm', 'package', name,
140             '--destination', td + '/',
141         ])
142 
143         subprocess.check_call([
144             'helm', 'repo', 'index', td,
145             '--url', published_repo,
146             '--merge', os.path.join(checkout_dir, 'index.yaml'),
147         ])
148 
149         # equivalent to `cp td/* checkout/`
150         # copies new helm chart and updated index.yaml
151         for f in os.listdir(td):
152             shutil.copy2(
153                 os.path.join(td, f),
154                 os.path.join(checkout_dir, f)
155             )
156     subprocess.check_call(['git', 'add', '.'], cwd=checkout_dir)
157     subprocess.check_call([
158         'git',
159         'commit',
160         '-m', '[{}] Automatic update for commit {}'.format(name, version)
161     ], cwd=checkout_dir)
162     subprocess.check_call(
163         ['git', 'push', 'origin', 'gh-pages'],
164         cwd=checkout_dir,
165     )
166 
167 
168 def main():
169     with open('chartpress.yaml') as f:
170         config = yaml.load(f)
171 
172     argparser = argparse.ArgumentParser()
173 
174     argparser.add_argument('--commit-range', help='Range of commits to consider when building images')
175     argparser.add_argument('--push', action='store_true')
176     argparser.add_argument('--publish-chart', action='store_true')
177     argparser.add_argument('--tag', default=None, help='Use this tag for images & charts')
178 
179     args = argparser.parse_args()
180 
181     for chart in config['charts']:
182         value_mods = build_images(chart['imagePrefix'], chart['images'], args.tag, args.commit_range, args.push)
183         build_values(chart['name'], value_mods)
184         chart_paths = ['.'] + chart.get('paths', [])
185         build_chart(chart['name'], paths=chart_paths, version=args.tag)
186         if args.publish_chart:
187             publish_pages(chart['name'],
188                 paths=chart_paths,
189                 git_repo=chart['repo']['git'],
190                 published_repo=chart['repo']['published'],
191             )
192 
193 main()
194
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/build.py b/build.py
--- a/build.py
+++ b/build.py
@@ -9,7 +9,7 @@
 
 # use safe roundtrip yaml loader
 yaml = YAML(typ='rt')
-yaml.indent(offset=2)
+yaml.indent(mapping=2, offset=2, sequence=4)
 
 def last_modified_commit(*paths, **kwargs):
     return subprocess.check_output([

{"golden_diff": "diff --git a/build.py b/build.py\n--- a/build.py\n+++ b/build.py\n@@ -9,7 +9,7 @@\n \n # use safe roundtrip yaml loader\n yaml = YAML(typ='rt')\n-yaml.indent(offset=2)\n+yaml.indent(mapping=2, offset=2, sequence=4)\n \n def last_modified_commit(*paths, **kwargs):\n     return subprocess.check_output([\n", "issue": "build.py corrupts yaml\n## Description\r\nI ran into an issue with entries in values.yaml file after using the build.py script. My `extraVolume` entries were corrupted.\r\n\r\n## Reproduction\r\n\r\n```yaml\r\n# create this file and name it values.yaml\r\nroot-1:\r\n  # offset=2 will indent the dash 2 spaces (default: 2)\r\n  # sequence=4 will indent indent-status-2 4 spaces and ignore what offset is used (default: 2)\r\n  - indent-status-1: ok\r\n    indent-status-2: bad after ./test.py runs\r\nroot-2:\r\n  # mapping=2 will indent the following entry 2 spaces (default: 2)\r\n  name: old-name\r\n```\r\n\r\n```python\r\n# create this runnable.py file, and run it\r\nimport os\r\nfrom ruamel.yaml import YAML\r\n\r\ndef main():\r\n    yaml = YAML()\r\n    yaml.indent(mapping=2, offset=2, sequence=4)\r\n\r\n    with open('values.yaml') as f:\r\n        values = yaml.load(f)\r\n\r\n    values['root-2'].update({'name': 'new-name'})\r\n\r\n    with open('values.yaml', 'w') as f:\r\n        yaml.dump(values, f)\r\n\r\n\r\nmain()\r\n```\r\n\r\n## Corrupt output\r\n\r\n#### Look at `indent-status-2`, it has a indentation causing the yaml to become corrupt.\r\n```yaml\r\n# create this file and name it values.yaml\r\nroot-1:\r\n  # offset=2 will indent the dash 2 spaces (default: 2)\r\n  # sequence=4 will indent indent-status-2 4 spaces and ignore what offset is used (default: 2)\r\n  - indent-status-1: ok\r\n  indent-status-2: bad after ./test.py runs\r\nroot-2:\r\n  # mapping=2 will indent the following entry 2 spaces (default: 2)\r\n  name: new-name\r\n```\nbuild.py corrupts yaml\n## Description\r\nI ran into an issue with entries in values.yaml file after using the build.py script. My `extraVolume` entries were corrupted.\r\n\r\n## Reproduction\r\n\r\n```yaml\r\n# create this file and name it values.yaml\r\nroot-1:\r\n  # offset=2 will indent the dash 2 spaces (default: 2)\r\n  # sequence=4 will indent indent-status-2 4 spaces and ignore what offset is used (default: 2)\r\n  - indent-status-1: ok\r\n    indent-status-2: bad after ./test.py runs\r\nroot-2:\r\n  # mapping=2 will indent the following entry 2 spaces (default: 2)\r\n  name: old-name\r\n```\r\n\r\n```python\r\n# create this runnable.py file, and run it\r\nimport os\r\nfrom ruamel.yaml import YAML\r\n\r\ndef main():\r\n    yaml = YAML()\r\n    yaml.indent(mapping=2, offset=2, sequence=4)\r\n\r\n    with open('values.yaml') as f:\r\n        values = yaml.load(f)\r\n\r\n    values['root-2'].update({'name': 'new-name'})\r\n\r\n    with open('values.yaml', 'w') as f:\r\n        yaml.dump(values, f)\r\n\r\n\r\nmain()\r\n```\r\n\r\n## Corrupt output\r\n\r\n#### Look at `indent-status-2`, it has a indentation causing the yaml to become corrupt.\r\n```yaml\r\n# create this file and name it values.yaml\r\nroot-1:\r\n  # offset=2 will indent the dash 2 spaces (default: 2)\r\n  # sequence=4 will indent indent-status-2 4 spaces and ignore what offset is used (default: 2)\r\n  - indent-status-1: ok\r\n  indent-status-2: bad after ./test.py runs\r\nroot-2:\r\n  # mapping=2 will indent the following entry 2 spaces (default: 2)\r\n  name: new-name\r\n```\n", "before_files": [{"content": "#!/usr/bin/env python3\nimport argparse\nimport os\nimport subprocess\nimport shutil\nfrom tempfile import TemporaryDirectory\n\nfrom ruamel.yaml import YAML\n\n# use safe roundtrip yaml loader\nyaml = YAML(typ='rt')\nyaml.indent(offset=2)\n\ndef last_modified_commit(*paths, **kwargs):\n    return subprocess.check_output([\n        'git',\n        'log',\n        '-n', '1',\n        '--pretty=format:%h',\n        *paths\n    ], **kwargs).decode('utf-8')\n\ndef last_modified_date(*paths, **kwargs):\n    return subprocess.check_output([\n        'git',\n        'log',\n        '-n', '1',\n        '--pretty=format:%cd',\n        '--date=iso',\n        *paths\n    ], **kwargs).decode('utf-8')\n\ndef path_touched(*paths, commit_range):\n    return subprocess.check_output([\n        'git', 'diff', '--name-only', commit_range, *paths\n    ]).decode('utf-8').strip() != ''\n\n\ndef render_build_args(options, ns):\n    \"\"\"Get docker build args dict, rendering any templated args.\"\"\"\n    build_args = options.get('buildArgs', {})\n    for key, value in build_args.items():\n        build_args[key] = value.format(**ns)\n    return build_args\n\ndef build_image(image_path, image_spec, build_args):\n    cmd = ['docker', 'build', '-t', image_spec, image_path]\n\n    for k, v in build_args.items():\n        cmd += ['--build-arg', '{}={}'.format(k, v)]\n    subprocess.check_call(cmd)\n\ndef build_images(prefix, images, tag=None, commit_range=None, push=False):\n    value_modifications = {}\n    for name, options in images.items():\n        image_path = os.path.join('images', name)\n        paths = options.get('paths', []) + [image_path]\n        last_commit = last_modified_commit(*paths)\n        if tag is None:\n            tag = last_commit\n        image_name = prefix + name\n        image_spec = '{}:{}'.format(image_name, tag)\n        value_modifications[options['valuesPath']] = {\n            'name': image_name,\n            'tag': tag\n        }\n\n        if commit_range and not path_touched(*paths, commit_range=commit_range):\n            print(f\"Skipping {name}, not touched in {commit_range}\")\n            continue\n\n        template_namespace = {\n            'LAST_COMMIT': last_commit,\n            'TAG': tag,\n        }\n\n        build_args = render_build_args(options, template_namespace)\n        build_image(image_path, image_spec, build_args)\n\n        if push:\n            subprocess.check_call([\n                'docker', 'push', image_spec\n            ])\n    return value_modifications\n\ndef build_values(name, values_mods):\n    \"\"\"Update name/values.yaml with modifications\"\"\"\n\n    values_file = os.path.join(name, 'values.yaml')\n\n    with open(values_file) as f:\n        values = yaml.load(f)\n\n    for key, value in values_mods.items():\n        parts = key.split('.')\n        mod_obj = values\n        for p in parts:\n            mod_obj = mod_obj[p]\n        mod_obj.update(value)\n\n\n    with open(values_file, 'w') as f:\n        yaml.dump(values, f)\n\n\ndef build_chart(name, version=None, paths=None):\n    \"\"\"Update chart with specified version or last-modified commit in path(s)\"\"\"\n    chart_file = os.path.join(name, 'Chart.yaml')\n    with open(chart_file) as f:\n        chart = yaml.load(f)\n\n    if version is None:\n        if paths is None:\n            paths = ['.']\n        commit = last_modified_commit(*paths)\n        version = chart['version'].split('-')[0] + '-' + commit\n\n    chart['version'] = version\n\n    with open(chart_file, 'w') as f:\n        yaml.dump(chart, f)\n\n\ndef publish_pages(name, paths, git_repo, published_repo):\n    \"\"\"publish helm chart index to github pages\"\"\"\n    version = last_modified_commit(*paths)\n    checkout_dir = '{}-{}'.format(name, version)\n    subprocess.check_call([\n        'git', 'clone', '--no-checkout',\n        'git@github.com:{}'.format(git_repo), checkout_dir],\n    )\n    subprocess.check_call(['git', 'checkout', 'gh-pages'], cwd=checkout_dir)\n\n    # package the latest version into a temporary directory\n    # and run helm repo index with --merge to update index.yaml\n    # without refreshing all of the timestamps\n    with TemporaryDirectory() as td:\n        subprocess.check_call([\n            'helm', 'package', name,\n            '--destination', td + '/',\n        ])\n\n        subprocess.check_call([\n            'helm', 'repo', 'index', td,\n            '--url', published_repo,\n            '--merge', os.path.join(checkout_dir, 'index.yaml'),\n        ])\n\n        # equivalent to `cp td/* checkout/`\n        # copies new helm chart and updated index.yaml\n        for f in os.listdir(td):\n            shutil.copy2(\n                os.path.join(td, f),\n                os.path.join(checkout_dir, f)\n            )\n    subprocess.check_call(['git', 'add', '.'], cwd=checkout_dir)\n    subprocess.check_call([\n        'git',\n        'commit',\n        '-m', '[{}] Automatic update for commit {}'.format(name, version)\n    ], cwd=checkout_dir)\n    subprocess.check_call(\n        ['git', 'push', 'origin', 'gh-pages'],\n        cwd=checkout_dir,\n    )\n\n\ndef main():\n    with open('chartpress.yaml') as f:\n        config = yaml.load(f)\n\n    argparser = argparse.ArgumentParser()\n\n    argparser.add_argument('--commit-range', help='Range of commits to consider when building images')\n    argparser.add_argument('--push', action='store_true')\n    argparser.add_argument('--publish-chart', action='store_true')\n    argparser.add_argument('--tag', default=None, help='Use this tag for images & charts')\n\n    args = argparser.parse_args()\n\n    for chart in config['charts']:\n        value_mods = build_images(chart['imagePrefix'], chart['images'], args.tag, args.commit_range, args.push)\n        build_values(chart['name'], value_mods)\n        chart_paths = ['.'] + chart.get('paths', [])\n        build_chart(chart['name'], paths=chart_paths, version=args.tag)\n        if args.publish_chart:\n            publish_pages(chart['name'],\n                paths=chart_paths,\n                git_repo=chart['repo']['git'],\n                published_repo=chart['repo']['published'],\n            )\n\nmain()\n", "path": "build.py"}], "after_files": [{"content": "#!/usr/bin/env python3\nimport argparse\nimport os\nimport subprocess\nimport shutil\nfrom tempfile import TemporaryDirectory\n\nfrom ruamel.yaml import YAML\n\n# use safe roundtrip yaml loader\nyaml = YAML(typ='rt')\nyaml.indent(mapping=2, offset=2, sequence=4)\n\ndef last_modified_commit(*paths, **kwargs):\n    return subprocess.check_output([\n        'git',\n        'log',\n        '-n', '1',\n        '--pretty=format:%h',\n        *paths\n    ], **kwargs).decode('utf-8')\n\ndef last_modified_date(*paths, **kwargs):\n    return subprocess.check_output([\n        'git',\n        'log',\n        '-n', '1',\n        '--pretty=format:%cd',\n        '--date=iso',\n        *paths\n    ], **kwargs).decode('utf-8')\n\ndef path_touched(*paths, commit_range):\n    return subprocess.check_output([\n        'git', 'diff', '--name-only', commit_range, *paths\n    ]).decode('utf-8').strip() != ''\n\n\ndef render_build_args(options, ns):\n    \"\"\"Get docker build args dict, rendering any templated args.\"\"\"\n    build_args = options.get('buildArgs', {})\n    for key, value in build_args.items():\n        build_args[key] = value.format(**ns)\n    return build_args\n\ndef build_image(image_path, image_spec, build_args):\n    cmd = ['docker', 'build', '-t', image_spec, image_path]\n\n    for k, v in build_args.items():\n        cmd += ['--build-arg', '{}={}'.format(k, v)]\n    subprocess.check_call(cmd)\n\ndef build_images(prefix, images, tag=None, commit_range=None, push=False):\n    value_modifications = {}\n    for name, options in images.items():\n        image_path = os.path.join('images', name)\n        paths = options.get('paths', []) + [image_path]\n        last_commit = last_modified_commit(*paths)\n        if tag is None:\n            tag = last_commit\n        image_name = prefix + name\n        image_spec = '{}:{}'.format(image_name, tag)\n        value_modifications[options['valuesPath']] = {\n            'name': image_name,\n            'tag': tag\n        }\n\n        if commit_range and not path_touched(*paths, commit_range=commit_range):\n            print(f\"Skipping {name}, not touched in {commit_range}\")\n            continue\n\n        template_namespace = {\n            'LAST_COMMIT': last_commit,\n            'TAG': tag,\n        }\n\n        build_args = render_build_args(options, template_namespace)\n        build_image(image_path, image_spec, build_args)\n\n        if push:\n            subprocess.check_call([\n                'docker', 'push', image_spec\n            ])\n    return value_modifications\n\ndef build_values(name, values_mods):\n    \"\"\"Update name/values.yaml with modifications\"\"\"\n\n    values_file = os.path.join(name, 'values.yaml')\n\n    with open(values_file) as f:\n        values = yaml.load(f)\n\n    for key, value in values_mods.items():\n        parts = key.split('.')\n        mod_obj = values\n        for p in parts:\n            mod_obj = mod_obj[p]\n        mod_obj.update(value)\n\n\n    with open(values_file, 'w') as f:\n        yaml.dump(values, f)\n\n\ndef build_chart(name, version=None, paths=None):\n    \"\"\"Update chart with specified version or last-modified commit in path(s)\"\"\"\n    chart_file = os.path.join(name, 'Chart.yaml')\n    with open(chart_file) as f:\n        chart = yaml.load(f)\n\n    if version is None:\n        if paths is None:\n            paths = ['.']\n        commit = last_modified_commit(*paths)\n        version = chart['version'].split('-')[0] + '-' + commit\n\n    chart['version'] = version\n\n    with open(chart_file, 'w') as f:\n        yaml.dump(chart, f)\n\n\ndef publish_pages(name, paths, git_repo, published_repo):\n    \"\"\"publish helm chart index to github pages\"\"\"\n    version = last_modified_commit(*paths)\n    checkout_dir = '{}-{}'.format(name, version)\n    subprocess.check_call([\n        'git', 'clone', '--no-checkout',\n        'git@github.com:{}'.format(git_repo), checkout_dir],\n    )\n    subprocess.check_call(['git', 'checkout', 'gh-pages'], cwd=checkout_dir)\n\n    # package the latest version into a temporary directory\n    # and run helm repo index with --merge to update index.yaml\n    # without refreshing all of the timestamps\n    with TemporaryDirectory() as td:\n        subprocess.check_call([\n            'helm', 'package', name,\n            '--destination', td + '/',\n        ])\n\n        subprocess.check_call([\n            'helm', 'repo', 'index', td,\n            '--url', published_repo,\n            '--merge', os.path.join(checkout_dir, 'index.yaml'),\n        ])\n\n        # equivalent to `cp td/* checkout/`\n        # copies new helm chart and updated index.yaml\n        for f in os.listdir(td):\n            shutil.copy2(\n                os.path.join(td, f),\n                os.path.join(checkout_dir, f)\n            )\n    subprocess.check_call(['git', 'add', '.'], cwd=checkout_dir)\n    subprocess.check_call([\n        'git',\n        'commit',\n        '-m', '[{}] Automatic update for commit {}'.format(name, version)\n    ], cwd=checkout_dir)\n    subprocess.check_call(\n        ['git', 'push', 'origin', 'gh-pages'],\n        cwd=checkout_dir,\n    )\n\n\ndef main():\n    with open('chartpress.yaml') as f:\n        config = yaml.load(f)\n\n    argparser = argparse.ArgumentParser()\n\n    argparser.add_argument('--commit-range', help='Range of commits to consider when building images')\n    argparser.add_argument('--push', action='store_true')\n    argparser.add_argument('--publish-chart', action='store_true')\n    argparser.add_argument('--tag', default=None, help='Use this tag for images & charts')\n\n    args = argparser.parse_args()\n\n    for chart in config['charts']:\n        value_mods = build_images(chart['imagePrefix'], chart['images'], args.tag, args.commit_range, args.push)\n        build_values(chart['name'], value_mods)\n        chart_paths = ['.'] + chart.get('paths', [])\n        build_chart(chart['name'], paths=chart_paths, version=args.tag)\n        if args.publish_chart:\n            publish_pages(chart['name'],\n                paths=chart_paths,\n                git_repo=chart['repo']['git'],\n                published_repo=chart['repo']['published'],\n            )\n\nmain()\n", "path": "build.py"}]}