def git_project_profile(): try: run('git status') cli.echo("""'swampo git add-all' -- Stage all files 'swampo git add-file FILE -- Stage particular files""") except sb.CalledProcessError: cli.echo('OOPS! Something went wrong!')
def git_init(directory): if 'current' in directory: run('git init') else: run(f'cd; cd {directory}; git init') cli.echo( "Your project has been initialised! Check your Project Info by typing 'swampo -g project-info" )
def git_push(inp): if inp == 1: try: rem = cli.prompt('Enter the remote variable') branch = cli.prompt('Enter the branch') run(f'git push -u {remote} {branch}') except sb.CalledProcessError: cli.echo('Something went wrong... ') elif inp == 2: try: run('git push') except sb.CalledProcessError: echo('Something went wrong...') else: cli.echo('Wrong Input!')
def create_ssh_key(email): try: run('ls -al ~/.ssh') print('You already have an SSH Key... ') except sb.CalledProcessError: cli.echo( '''> Enter a file in which to save the key (/home/you/.ssh/id_ed25519): [Press enter] > Enter passphrase (Press Enter for no passphrase): [Type a passphrase] > Enter same passphrase again: [Type passphrase again]''') run(f'ssh-keygen -t ed25519 -C "{email}"') run(f'eval "$(ssh-agent -s)"; ssh-add ~/.ssh/id_ed25519') cli.echo( "An SSH Key was generated in '~/.ssh/id_ed25519.pub'. Now you can add the key in Github" )
def set_remote(name, link): try: run(f'git remote add {name} {link}') except sb.CalledProcessError: cli.echo('Something went wrong. Did you type a valid link?')
def changeGitConfig(name, email): run(f'git config --global user.name {name}') run(f'git config --global user.email {email}')
def git_pull(link, directory): if 'current' in directory: run(f'git pull {link}') else: run(f'cd; cd {directory}; git pull {link}')
def git_clone(link, directory): if 'current' in directory: run(f'git clone {link}') else: run(f'cd; cd {directory}; git clone {link}')
def gitaddf(arg): try: run(f'git add {arg}') cli.echo('Files were added successfully!') except Exception as e: cli.echo('Something went wrong!')
def gitadd(): try: run('git add .') except sb.CalledProcessError: cli.echo('Something went wrong!')