GithubHelp home page GithubHelp logo

inspirezonetech / automategitreposetup Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 8.0 40 KB

Automate creation of a local repo on your PC and a remote repo on Github in one click.

Home Page: https://inspirezone.tech/automate-git-local-and-remote-repo-setup-python/

License: MIT License

Python 100.00%
python github-api git-automation configuration-file hacktoberfest hacktoberfest2021 hacktoberfest-accepted

automategitreposetup's Introduction

AutomateGitRepoSetup

You are welcome to contribute to this repo. See the CONTRIBUTING.md for more info.

AutomateGitRepoSetup

Tutorial available

A full tutorial walking you through this program is detailed on the inspirezone.tech blog post: Github API use case: Automate git local and remote repo setup with Python.

The repo source files have gone through major modifications since the tutorial was written. You can see the original tutorial files under the folder blog-tutorial-original-code/. Use the code found in this folder to follow along with the blog tutorial.

About this repo

Automate creation of a local repo on your PC and a remote repo on Github.

One a single run of the script it will:

  • Init a local repo
  • Create a file in the repo
  • Commit the file
  • Create a repo on Github using same name as local repo
  • Get origin URL for created repo on Github
  • Push local repo to Github repo

Technologies used

Setup instructions

Step 1: Install Curl

Curl is a command line tool for transferring data using network protocols such as HTTPS. We use this tool to interact with the Github API.

For Ubuntu systems curl can be installed by running:

sudo apt-get install curl

For other systems see the curl installation guidelines

Step 2: Setup the config.ini file

Fill in your settings before running the script. An example configuration:

[your_settings]

; enter your github token for authorization purposes
github_token = 0000111122223333444455556666777788889999

; directory to create the repo on your computer
directory = /pathto/yourfolder/

; name of the repo
repo_name = your_repo_name

; first committed file
commit_file = README.md

; first commit message
first_commit_msg = first commit

; your github user name
github_name = your_github_name

; optional final command to run in repo directory e.g. "code ."
cmd = code .

The github_token is a personal access token generated from your Github account. It allows you to authenticate to Github when using the API. Follow the Github docs instructions on how to generate a personal access token.

Step 3: Run the script

Run python script using

python automate_git.py

Running the test program using pytest

The file test_automate_git.py is used to execute a test program to check basic functionality of the application.

To run the test do the following:

Install modules pytest and gitpython using requirements.txt.

pip install -r requirements.txt

Execute the test program

pytest test_automate_git.py

automategitreposetup's People

Contributors

funbeedev avatar stedders avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

automategitreposetup's Issues

Update workflow to execute on any branch, not just main

Current Behaviour

Some workflows only execute on the main branch. This means using any other branch name e.g. a branch on a fork, will not run the workflow.

Changes Requested

Edit workflow that executes only on main branch to execute on any branch.

Add .gitignore to repo

Current Behaviour

.gitignore does not exist

Changes Requested

Add .gitignore file to root of repo to ignore any generated files from running automate_git.py and test_automate_git.py.
To prevent someone committing unnecessary files to the repo.

Update with instructions on how to run test

Current Behaviour

No instructions for how to run the pytest program

Changes Requested

Add instructions to readme including:

  • Add requirements.txt with requirements to install - pytest gitpython
  • how to run test using pytest

Add exception handling

Current Behaviour

No exception handling. Any failed step will result in an unexpected behaviour.

Changes Requested

Add exception handling to print error messages if exceptions occur in various stages of the program.

Port application to Windows

Current Behaviour

Only works on Linux systems.

Changes Requested

Port so it successfully works on a Windows machine.

Refactor to avoid use of global variables

Current Behaviour

The config variables are defined at the top of the python file and all functions can make use of them.

Changes Requested

Edit code so only the relevant configs are passed into each function as an argument.

Pass the config file as a variable into the program

Current Behaviour

The config file is not passed into any program function. The file path is simply hardcoded.

Changes Requested

Pass the config file into the program via a parameter e.g. start_program_flow(config_file) . This will allow flexibility in which config file is used when running the program.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.