Skip to content

Commit

Permalink
Fallback to old code in updatesnapyaml.py when yaml-path is not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
rudra-iitm committed Nov 28, 2024
1 parent d3f805a commit 2046d91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inputs:
yaml-path:
description: 'Path to the YAML file'
required: false
default: 'snapcraft.yaml'
default: 'None'

# Outputs generated by running this action.
outputs:
Expand Down
16 changes: 15 additions & 1 deletion updatesnap/updatesnapyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def get_working_branch(self, project_url):
def get_yaml_file(self, project_url, yaml_path):
""" Searches in a project for the 'snapcraft.yaml' file and
returns its contents """
if yaml_path != 'None':
try:
data = self._github.get_file(project_url, yaml_path)
except (ValueError, ConnectionError):
data = None
return data

yaml_path = 'snapcraft.yaml'
try:
data = self._github.get_file(project_url, yaml_path)
except (ValueError, ConnectionError):
Expand All @@ -53,6 +61,12 @@ def get_yaml_file(self, project_url, yaml_path):
data = self._github.get_file(project_url, yaml_path)
except (ValueError, ConnectionError):
data = None
if not data:
yaml_path = 'rockcraft.yaml'
try:
data = self._github.get_file(project_url, yaml_path)
except (ValueError, ConnectionError):
data = None
return data


Expand All @@ -69,7 +83,7 @@ def main():
help='Version schema of snapping repository')
parser.add_argument('--rock-version-schema', action='store', default='None',
help='Version schema of rock repository')
parser.add_argument('--yaml-path', action='store', default='snapcraft.yaml',
parser.add_argument('--yaml-path', action='store', default='None',
help='Path to the yaml file')
parser.add_argument('--verbose', action='store_true', default=False)
parser.add_argument('project', default='.', help='The project URI')
Expand Down

0 comments on commit 2046d91

Please sign in to comment.