PK!xgit/__init__.pyPK!H2xgit/__main__.pyimport sys import subprocess import shlex from pathlib import Path import requests from .utils import trim_indent, call_multiline def main(): argv = sys.argv if len(argv) <= 1: cli_default() elif argv[1] == "init": cli_init() elif argv[1] in {"commit", "cpush"}: try: cli_commit(argv[2]) except IndexError: cli_commit(input("Please input your commit message: ")) if argv[1] == "cpush": cli_push() elif argv[1] == "gi": cli_gi() elif argv[1] == "push": cli_push() elif argv[1] in {"-h", "--help", "help"}: print(trim_indent(""" Acceptable commands: xgit init Initialize new git along with .gitignore xgit commit message Commit to git with the following message xgit cpush message Commit and push to git with the following message xgit gi Generate gitignore from files in the directory xgit push Push changes to origin xgit Prompt for choices """)) def cli_default(): choice = input(trim_indent(""" What do you want to do? 1. Initialize Git 2. Commit current changes 3. Commit current changes and push to remote 4. Generate and commit .gitignore 5. Push to remote Please select [1-5]: """)) if choice == "1": cli_init() elif choice in {"2", "3"}: cli_commit(input("Please input your commit message: ")) if choice == "3": cli_push() elif choice == "4": cli_gi() elif choice == "5": cli_push() def cli_init(): cli_gi(_commit=False) subprocess.call(["git", "init"]) def cli_commit(s: str): call_multiline(""" git add . git commit -m {} """.format(shlex.quote(s))) def cli_gi(_commit=True): old_gitignore_rows = Path(".gitignore").read_text().split("\n") with open(".gitignore", "w+") as f: f.write(Path(__file__).parent.joinpath("gitignore/{}.gitignore".format("global")).read_text()) matched = set() for spec, filetypes in { "py": ["py"], "jvm": ["java", "kt"], "dart": ["dart"] }.items(): for filetype in filetypes: try: next(Path(".").glob("**/*.{}".format(filetype))) if spec not in matched: f.write(Path(__file__).parent.joinpath("gitignore/{}.gitignore".format(spec)).read_text()) matched.add(spec) matched.add(filetype) except StopIteration: pass if len(matched) > 0: r = requests.get("https://www.gitignore.io/api/{}".format(",".join({ "kt": "kotlin", "py": "python" }.get(k, k) for k in matched))) f.write(r.text) f.seek(0) new_gitignore_rows = f.read().strip().split() for row in old_gitignore_rows: if row not in new_gitignore_rows: f.write(row + "\n") if _commit: subprocess.call(["sh", "-c", "git ls-files -i --exclude-from=.gitignore | xargs git rm --cached"]) cli_commit(input("Please input your commit message.")) def cli_push(): if not subprocess.check_output(["git", "config", "remote.origin.url"]): subprocess.call(["git", "remote", "add", "origin", shlex.quote(input("Please input the Git origin: "))]) subprocess.call(["git", "push", "origin", "master"]) PK!͐xgit/gitignore/dart.gitignore.pub/ PK!: xgit/gitignore/global.gitignore.vscode/ PK!exgit/gitignore/jvm.gitignore.idea/ PK!exgit/gitignore/py.gitignore.idea/ PK!_ xgit/utils.pyimport re import subprocess def trim_indent(s: str) -> str: def process_match(match_obj): if match_obj is None: return 0 else: return len(match_obj.group()) rows = s.lstrip("\n").rstrip().split("\n") ws = min(process_match(re.match(r" +", r)) for r in rows) return "\n".join(r[ws:] for r in rows) def call_multiline(s: str): for row in trim_indent(s).split("\n"): if row.strip(): subprocess.call(["sh", "-c", row.strip()]) PK!Hk(+%xgit-0.1.2.dist-info/entry_points.txtN+I/N.,()H,z񹉙yV PK!HnHTUxgit-0.1.2.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H%RQxgit-0.1.2.dist-info/METADATAT]O0}{[cC -7Z.יQ9=]O.-\4m|msW] R"rLV \ ֩?$c]2oɗ?:݃tKXP/8 jScId,dnuiy] UWeC=R?:#ޭI9g`i;>:8a;><vkd'r+']%ZyT>n  Tmud_lk fy.%8wRs k0¤1"p.,R YFR+ǘ$:`#.,8U;}9*4y/ 덣YwD $9%(uFzh+.#T {ZcpE]( ݖ&1"RebUOZ40K)`sBKҁ'\BfcD w)b-jTQmڊREW62*M׍aM>BwC*SlnrMretAXK7efyƖZ{d隄`g1IKC%_[uPK!HD@xgit-0.1.2.dist-info/RECORD9P|~ r l!0"$rx\w,vl:%+&A+2!AxKV!8J㢴*$9ֵ^uۣoCi¢K(I`y:v@Dzߗ $R3Ev !TH FTdh( ׶,\MN1 c_.Jfuw h"[}& c';E|萕7 +ZNWQlHѬАFgt'D8_OЪ)3y#,C001^͠!\rʁ"i?ǶѢMMB}Wp*,+ZU܅\mfzE *R4PveQ<=Ac-G"pEP^dy*Ȟ ϣY{P~;Ӵ9 uRJޮ0^ۉoBP } ,Q0=PK!xgit/__init__.pyPK!H2.xgit/__main__.pyPK!͐\xgit/gitignore/dart.gitignorePK!: xgit/gitignore/global.gitignorePK!exgit/gitignore/jvm.gitignorePK!e$xgit/gitignore/py.gitignorePK!_ dxgit/utils.pyPK!Hk(+%xgit-0.1.2.dist-info/entry_points.txtPK!HnHTUxgit-0.1.2.dist-info/WHEELPK!H%RQxgit-0.1.2.dist-info/METADATAPK!HD@xgit-0.1.2.dist-info/RECORDPK