示例#1
0
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!')
示例#2
0
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"
    )
示例#3
0
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!')
示例#4
0
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"
        )
示例#5
0
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?')
示例#6
0
def changeGitConfig(name, email):
    run(f'git config --global user.name {name}')
    run(f'git config --global user.email {email}')
示例#7
0
def git_pull(link, directory):
    if 'current' in directory:
        run(f'git pull {link}')
    else:
        run(f'cd; cd {directory}; git pull {link}')
示例#8
0
def git_clone(link, directory):
    if 'current' in directory:
        run(f'git clone {link}')
    else:
        run(f'cd; cd {directory}; git clone {link}')
示例#9
0
def gitaddf(arg):
    try:
        run(f'git add {arg}')
        cli.echo('Files were added successfully!')
    except Exception as e:
        cli.echo('Something went wrong!')
示例#10
0
def gitadd():
    try:
        run('git add .')
    except sb.CalledProcessError:
        cli.echo('Something went wrong!')