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

Add Git push to 3) Publish button menu #38

Open
PFython opened this issue Jan 6, 2021 · 0 comments
Open

Add Git push to 3) Publish button menu #38

PFython opened this issue Jan 6, 2021 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@PFython
Copy link
Owner

PFython commented Jan 6, 2021

easyPyPI helps new Pythonistas by automatically creating and initialising a Github Repository. The author doesn't use git commands usually and just pasted in the recommended incantations from Github itself:

def publish_to_github(self):
    """ Uploads initial package to Github using Git"""
    if not self.get_username("Github"):
        return False
    commands = f"""
    git init
    git add *.*
    git commit -m "Committing version {self.version}"
    git branch -M main
    git remote add origin https://github.com/{self.Github_username}/{self.name}.git
    git push -u origin main
    """
    choice = sg.popup_yes_no(
        f"Do you want to upload (Push) your package to Github?\n\n ⚠   CAUTION - "
        f"Only recommended when creating your repository for the first time!  "
        f"This automation requires Git and will run the following commands:\n\n{commands}",
        **SG_KWARGS,
    )
    if choice != "Yes":
        return False
    os.chdir(self.setup_filepath.parent)
    for command in commands.splitlines()[1:]:  # Ignore first blank line
        if not os.system(f"cmd /c {command}"):
            # A return value of 1 indicates an error, 0 indicates success
            print(f"\n ⓘ  Your package is now online at:\n  {self.url}':\n")

Although easyPyPI isn't intended to replace the git or Github client or the numerous plugins and extensions to IDEs that help with version control, it might be a nice convenience function to add the ability to Push the latest Repository to Github immediately after publishing on PyPI.

If anyone can help with the correct git incantations and a little logic to check things are set up correctly ready for the Push, please do contribute and send a Pull Request! Many thanks :)

@PFython PFython added enhancement New feature or request good first issue Good for newcomers labels Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant