diff --git a/README.md b/README.md index 480dbaa..a6c8551 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ So far, the following projects have been integrated to this repo: |[File Sharing Bot](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/File-Sharing-Bot) | [Darshan Patel](https://github.com/DarshanPatel11)| |[Flash card quizzer](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Flash-card-Challenge) |[Utkarsh Sharma](https://github.com/Utkarsh1308) | |[Frammed text generator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/FramedText) | [jcdwalle](https://github.com/jcdwalle)| +|[git_automation](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/git_automation)| [loge1998](https://github.com/loge1998)| |[Gmail Mailing Script](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/mailing) |[mayank-kapur](https://github.com/kapurm17) | |[Handwrting DNN recognizer](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Handwriting_Recognizer) |[Chris]() | |[HTML Table to List](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/HTML_Table_to_List) | [Nitish Srivastava](https://github.com/nitish-iiitd)| diff --git a/git_automation/.my_commands.sh b/git_automation/.my_commands.sh new file mode 100755 index 0000000..62599c5 --- /dev/null +++ b/git_automation/.my_commands.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +function create() { + cd + source .env + python create.py $1 + cd $FILEPATH$1 + git init + git remote add origin git@github.com:$USERNAME/$1.git + touch README.md + git add . + git commit -m "Initial commit" + git push -u origin main + code . +} + + diff --git a/git_automation/README.md b/git_automation/README.md new file mode 100755 index 0000000..b61561c --- /dev/null +++ b/git_automation/README.md @@ -0,0 +1,12 @@ +### Install: +```bash +pip install -r requirements.txt +touch .env +Then open the .env file and store your username, password, and desired file destination. Use the provided format at the bottom of this README. +source ~/.my_commands.sh +``` + +### Usage: +```bash +To run the script type in 'create ' +``` diff --git a/git_automation/config.env b/git_automation/config.env new file mode 100644 index 0000000..c17534b --- /dev/null +++ b/git_automation/config.env @@ -0,0 +1,3 @@ +USERNAME="User" +PASSWORD="Pass" +FILEPATH="/path/to/your/project/" \ No newline at end of file diff --git a/git_automation/create.py b/git_automation/create.py new file mode 100755 index 0000000..2d49b6a --- /dev/null +++ b/git_automation/create.py @@ -0,0 +1,24 @@ +import sys +import os +from github import Github +from dotenv import load_dotenv + +load_dotenv() + +path = os.getenv("FILEPATH") +username = os.getenv("USERNAME") +password = os.getenv("PASSWORD") + +def create(): + folderName = str(sys.argv[1]) + folderpath = os.path.join(path,folderName) + if os.path.exists(folderpath): + print("Folder already exists.. Link to the path - "+ folderpath) + os.makedirs(folderpath) + user = Github(username, password).get_user() + repo = user.create_repo(sys.argv[1]) + print("Succesfully created repository {}".format(sys.argv[1])) + + +if __name__ == "__main__": + create() diff --git a/git_automation/requirements.txt b/git_automation/requirements.txt new file mode 100755 index 0000000..0460963 --- /dev/null +++ b/git_automation/requirements.txt @@ -0,0 +1,3 @@ +selenium +PyGithub +python-dotenv