added
This commit is contained in:
51
create_mygit_default_conf/main.py
Normal file
51
create_mygit_default_conf/main.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#! /usr/bin/env python3.10
|
||||
|
||||
import os, configparser
|
||||
|
||||
#Set Skript Vars
|
||||
user_gitconfig = os.environ["HOME"] + os.sep + ".gitconfig"
|
||||
config_ini = configparser.ConfigParser()
|
||||
|
||||
|
||||
list_my_git_projects = [
|
||||
"https://gitea.schlaubistechtalk.de",
|
||||
"https://gitlab.com",
|
||||
"https:ubuntu:5000"
|
||||
]
|
||||
my_username = "jonnybravo"
|
||||
|
||||
if not os.path.exists(user_gitconfig):
|
||||
os.popen("touch " + user_gitconfig)
|
||||
|
||||
config_ini.read(user_gitconfig)
|
||||
if not config_ini.has_section("user"):
|
||||
config_ini.add_section("user")
|
||||
config_ini.set("user", "email", "mr.blue82@gmail.com")
|
||||
config_ini.set("user", "name", my_username)
|
||||
if not config_ini.has_section("core"):
|
||||
config_ini.add_section("core")
|
||||
config_ini.set("core", "editor", '"vim"')
|
||||
config_ini.set("core", "pager", '"less --raw - control - chars"')
|
||||
config_ini.set("core", "autocrlf","false" )
|
||||
if not config_ini.has_section("init"):
|
||||
config_ini.add_section("init")
|
||||
config_ini.set("init", "defaultBranch", "main")
|
||||
if not config_ini.has_section("credential"):
|
||||
config_ini.add_section("credential")
|
||||
config_ini.set("credential", "helper", "store")
|
||||
config_ini.set("credential", "helper", "cache –timeout=9640")
|
||||
|
||||
for my_git_site in list_my_git_projects:
|
||||
if not config_ini.has_section("credential " + '"' + my_git_site + '"'):
|
||||
config_ini.add_section("credential " + '"' + my_git_site + '"')
|
||||
config_ini.set("credential " + '"' + my_git_site + '"', "username", my_username)
|
||||
|
||||
if not config_ini.has_section("URL " + '"' + my_git_site + '"'):
|
||||
config_ini.add_section("URL " + '"' + my_git_site + '"')
|
||||
config_ini.set("URL " + '"' + my_git_site + '"', "insteadOf", 'git@' + my_git_site + ":")
|
||||
|
||||
#writing_all_configs
|
||||
with open(user_gitconfig, "w") as configfile:
|
||||
config_ini.write(configfile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user