diff --git a/Git_repo_creator/README.md b/Git_repo_creator/README.md new file mode 100644 index 0000000..96d09b9 --- /dev/null +++ b/Git_repo_creator/README.md @@ -0,0 +1,15 @@ +# Github Repo Creator +A simple python script which will take git username , git token, git repo name and description from user and it will create a github repo. + +## How to create github token [https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token] + +## Libraries Required +1. Requests: HTTP for Humans +`$pip install requests` + +## Usage +1. Go to the script's folder and open command prompt. +2. Run command : `$python3 git_repo_creator.py + +## Example +`$python3 git_repo_creator.py diff --git a/Git_repo_creator/git_repo_creator.py b/Git_repo_creator/git_repo_creator.py new file mode 100644 index 0000000..97e0c4f --- /dev/null +++ b/Git_repo_creator/git_repo_creator.py @@ -0,0 +1,33 @@ +# Script Name : git_repo_creator.py +# Author : Harish Tiwari +# Created : 2nd October 2020 +# Last Modified : - +# Version : 1.0.0 + +# Modifications : + +# Description : This python script will create a github repo from command line. + +import requests +import json + +user_name = input("Enter your github user name: ") +print(user_name) + +github_token = input("Enter your github token: ") +print(github_token) + +repo_name = input("Enter your repo Name: ") +print(repo_name) + +repo_description = input("Enter your repo description: ") +print(repo_description) + +payload = {'name': repo_name, 'description': repo_description, 'auto_init': 'true'} +repo_request = requests.post('https://api.github.com/' + 'user/repos', auth=(user_name,github_token), data=json.dumps(payload)) +if repo_request.status_code == 422: + print("Github repo already exists try wih other name.") +elif repo_request.status_code == 201: + print("Github repo has created successfully.") +elif repo_request.status_code == 401: + print("You are unauthorized user for this action.") diff --git a/README.md b/README.md index 177d24a..bc75b13 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ So far, the following projects have been integrated to this repo: | [Py_Cleaner](Py_Cleaner) | [Abhishek Dobliyal](https://github.com/Abhishek-Dobliyal) |[Send messages to sqs in parallel](send_sqs_messages_in_parallel)|[Jinam Shah](https://github.com/jinamshah)| |[Codeforces Checker](codeforcesChecker)|[Jinesh Parakh](https://github.com/jineshparakh)| +|[Github repo creator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Git_repo_creator)|[Harish Tiwari ](https://github.com/optimist2309) ## How to use :