Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(commands/commit): create tmp file divided by user info #316

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

Closed

Conversation

Copy link
Contributor

@SHAQ522 SHAQ522 commented Dec 16, 2020

For multi user siuation, it may get fail

Permission denied: '/tmp/cz.commit.backup'

The reason is another user has already created a temp file with the same name.
So if one user create temp_file should attatch with $USER info to resolve permission issue

Description

attach user info to temp-file name when $USER is possible

Checklist

  • Add test cases to all the changes you introduce
  • Run ./script/format and ./script/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

create /tmp/cz.commit.backup.tom

Steps to Test This Pull Request

Additional context

Lee-W reacted with thumbs up emoji
For multi user siuation, it may get fail `Permission denied: '/tmp/cz.commit/backup` due to another user create a temp file.
So if one user create temp_file should attatch with USER info to resolve permission issue
Copy link
Member

woile commented Dec 16, 2020

Nice, thanks! You'll have to run ./scripts/format and the tests will pass

Lee-W reacted with thumbs up emoji

self.temp_file: str = os.path.join(tempfile.gettempdir(), "cz.commit.backup")
name = "cz.commit.backup"
if "USER" in os.environ:
name = name + "." + os.environ['USER']
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer something like this:

user = os.environ.get('USER', "")
name = f"cz.commit{user}.backup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the apply. we have 100+ users project using this package which have this issue, but I am new commiter for this python package. I will rebuild this issue only after work.

Copy link
Member

Choose a reason for hiding this comment

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

No rush, take your time

name = name + "." + os.environ['USER']
self.temp_file: str = os.path.join(tempfile.gettempdir(), name)

def read_backup_message(self) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the file be read here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@woile woile woile left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /