Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repos: improved parsing of the 'series' file #98

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lejcik
Copy link

@lejcik lejcik commented Apr 25, 2023

fixes #96

lejcik added 2 commits April 7, 2023 11:08
When kas applies patches and the 'series' file contains an empty line or
whitespaces before comment, it fails on error FileNotFoundError, which has
nothing to do with a file operation, it's only a parsing issue.

This patch fixes issue with parsing the 'series' file. Moreover, test files
were updated to cover such case.

siemens#96

Signed-off-by: Viliam Lejcik <[email protected]>
for line in f:
if line.startswith('#'):
ln += 1
if not line.rstrip('\n') or line.startswith('#'):
Copy link
Author

@lejcik lejcik Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

condition with rstrip('\n') accepts empty lines \n, but not any whitespace on the line, e.g. \n

continue
p = os.path.join(path, line.split(' #')[0].rstrip())
pn = line.split(' #')[0].rstrip()
if not pn:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle error if patch name pn is parsed as empty string

self.name,
patch['id'])
return 1
p = os.path.join(path, pn)
if os.path.isfile(p):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line behaves strange on my linux with python ver. 3.10.7,

if pn contains space at the beginning (e.g. 001.patch), isfile() says that such path p exists, and error appears later when patch is about to be applied,

pn = line.split(' #')[0].rstrip()
if not pn:
logging.error('Could not parse patch file name from a \'series\' file. '
'(file: %s, line: %d, repo: %s, patch entry: %s)',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if the error message is clear enough, or should it be rephrased?

@jan-kiszka
Copy link
Collaborator

MRs are not systematically reviewed by the community. I would recommend to follow up with a "v2" of your patch on the mailing list.

@jan-kiszka
Copy link
Collaborator

What's the status of this proposal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing error when KAS applies patches with quilt
2 participants