Exemple #1
0
def manage_branch():
    os.system("cls")
    print(branch)
    task_input = input()
    if task_input == "1":
        # Set branches permissions
        project_key = calling.project_key()
        print(calling.bitbucket.set_branches_permissions(project_key, multiple_permissions=False, matcher_type=None, matcher_value=None, permission_type=None, repository=None, except_users=[], except_groups=[], except_access_keys=[], start=0, limit=25))
        input("press any key to continue")
        main.menu()
    elif task_input == "2":
        # Delete a single branch permission by premission id
        project_key = calling.project_key()
        permission_id = input("Enter permission id \n")
        repository = input("Enter repository \n")
        print(calling.bitbucket.delete_branch_permission(project_key, permission_id, repository))
        input("press any key to continue")
        main.menu()
    elif task_input == "3":
        # Get a single branch permission by permission id
        project_key = calling.project_key()
        permission_id = input("Enter permission id \n")
        repository = input("Enter repository \n")
        print(calling.bitbucket.get_branch_permission(project_key, permission_id, repository))
        input("press any key to continue")
        main.menu()
    elif task_input == "4":
        os.system("cls")
        main.menu()
    else:
        manage_branch()
Exemple #2
0
def manage_pull():
    os.system("cls")
    print(pull)
    task_input = input()
    if task_input == "1":
        # Decline pull request
        project_key = calling.project_key()
        pr_id = input("Enter pull request id \n")
        pr_version = input("Enter pull request version \n")
        repository = input("Enter repository \n")
        print(
            calling.bitbucket.decline_pull_request(project_key, repository,
                                                   pr_id, pr_version))
        input("press any key to continue")
        main.menu()
    elif task_input == "2":
        # Check if pull request can be merged
        project_key = calling.project_key()
        pr_id = input("Enter pull request id \n")
        repository = input("Enter repository \n")
        print(
            calling.bitbucket.is_pull_request_can_be_merged(
                project_key, repository, pr_id))
        input("press any key to continue")
        main.menu()
    elif task_input == "3":
        # Merge pull request
        project_key = calling.project_key()
        pr_id = input("Enter pull request id \n")
        pr_version = input("Enter pull request version \n")
        repository = input("Enter repository \n")
        print(
            calling.bitbucket.bitbucket.merge_pull_request(
                project_key, repository, pr_id, pr_version))
        input("press any key to continue")
        main.menu()
    elif task_input == "4":
        # Reopen pull request
        project_key = calling.project_key()
        pr_id = input("Enter pull request id \n")
        pr_version = input("Enter pull request version \n")
        repository = input("Enter repository \n")
        print(
            calling.bitbucket.reopen_pull_request(project_key, repository,
                                                  pr_id, pr_version))
        input("press any key to continue")
        main.menu()
    elif task_input == "5":
        os.system("cls")
        main.menu()
    else:
        manage_pull()
Exemple #3
0
def manage_project():
    os.system("cls")
    # key = calling.project_key()
    print(project)
    task_input = input()
    if task_input == "1":
        # Project list
        print(calling.bitbucket.project_list())
        input("press any key to continue")
        main.menu()
    elif task_input == "2":
        # Repo list
        project_key = calling.project_key()
        print(calling.bitbucket.repo_list(project_key))
        input("press any key to continue")
        main.menu()
    elif task_input == "3":
        # Project info
        project_key = calling.project_key()
        print(calling.bitbucket.project(project_key))
        input("press any key to continue")
        main.menu()
    elif task_input == "4":
        # Create project
        project_key = calling.project_key()
        name = input("Enter project name \n")
        description = input("Enter description \n")
        print(calling.bitbucket.create_project(project_key, name, description))
        input("press any key to continue")
        main.menu()
    elif task_input == "5":
        # Get users who has permission in project
        project_key = calling.project_key()
        limit = input("Enter limit \n")
        print(
            calling.bitbucket.project_users(project_key,
                                            limit,
                                            filter_str=None))
        input("press any key to continue")
        main.menu()
    elif task_input == "6":
        # Get project administrators for project
        project_key = calling.project_key()
        print(
            calling.bitbucket.project_users_with_administrator_permissions(
                project_key))
        input("press any key to continue")
        main.menu()
    elif task_input == "7":
        # Get Project Groups
        project_key = calling.project_key()
        limit = input("Enter limit \n")
        print(
            calling.bitbucket.project_groups(project_key,
                                             limit,
                                             filter_str=None))
        input("press any key to continue")
        main.menu()
    elif task_input == "8":
        # Get groups with admin permissions
        project_key = calling.project_key()
        print(
            calling.bitbucket.project_groups_with_administrator_permissions(
                project_key))
        input("press any key to continue")
        main.menu()
    elif task_input == "9":
        # Project summary
        project_key = calling.project_key()
        print(calling.bitbucket.project_summary(project_key))
        input("press any key to continue")
        main.menu()
    elif task_input == "10":
        # Grant project permission to an specific user
        project_key = calling.project_key()
        username = input("Enter your username \n")
        permission = input("Enter your permission \n")
        print(
            calling.bitbucket.project_grant_user_permissions(
                project_key, username, permission))
        input("press any key to continue")
        main.menu()
    elif task_input == "11":
        # Grant project permission to an specific group
        project_key = calling.project_key()
        groupname = input("Enter your group name \n")
        permission = input("Enter your permission \n")
        print(
            calling.bitbucket.project_grant_group_permissions(
                project_key, groupname, permission))
        input("press any key to continue")
        main.menu()
    elif task_input == "12":
        os.system("cls")
        main.menu()
    else:
        manage_project()
def manage_repo():
    os.system("cls")
    print(repo)
    task_input = input()
    if task_input == "1":
        # Get single repository
        project_key = calling.project_key()
        repository_slug = input("Enter repository slug \n")
        print(calling.bitbucket.get_repo(project_key, repository_slug))
        input("press any key to continue")
        main.menu()
    elif task_input == "2":
        # Disable branching model
        project_key = calling.project_key()
        repo_key = input("Enter repository key \n")
        print(calling.bitbucket.disable_branching_model(project_key, repo_key))
        input("press any key to continue")
        main.menu()
    elif task_input == "3":
        # Enable branching model
        project_key = calling.project_key()
        repo_key = input("Enter repository key \n")
        print(calling.bitbucket.enable_branching_model(project_key, repo_key))
        input("press any key to continue")
        main.menu()
    elif task_input == "4":
        # Get branching model
        project_key = calling.project_key()
        repo_key = input("Enter repository key \n")
        print(calling.bitbucket.get_branching_model(project_key, repo_key))
        input("press any key to continue")
        main.menu()
    elif task_input == "5":
        input("For future use, press any key")
        os.system("cls")
        main.menu()
    elif task_input == "6":
        # Grant repository permission to an specific user
        project_key = calling.project_key()
        repo_key = input("Enter repository key \n")
        username = input("Enter username \n")
        permission = input("Enter permission \n")
        print(calling.bitbucket.repo_grant_user_permissions(project_key, repo_key, username, permission)) 
        input("press any key to continue")
        main.menu()
    elif task_input == "7":
        # Grant repository permission to an specific group
        project_key = calling.project_key()
        repo_key = input("Enter repository key \n")
        groupname = input("Enter groupname \n")
        permission = input("Enter permission \n")
        print(calling.bitbucket.repo_grant_group_permissions(project_key, repo_key, groupname, permission))
        input("press any key to continue")
        main.menu()
    elif task_input == "8":
        # Delete a repository (DANGER!)
        project_key = calling.project_key()
        repository_slug = input("Enter repository slug \n")  
        print(calling.bitbucket.delete_repo(project_key, repository_slug)) 
        input("press any key to continue")
        main.menu()
    elif task_input == "9":
        os.system("cls")
        main.menu()
    else:
        manage_repo()
Exemple #5
0
def manage_code():
    os.system("cls")
    print(code)
    task_input = input()
    if task_input == "1":
        # Get repositories list from project
        project_key = calling.project_key()
        limit = input("Enter limit \n")
        print(calling.bitbucket.repo_list(project_key, limit))
        input("press any key to continue")
        main.menu()
    elif task_input == "2":
        # Create a new repository.
        project_key = calling.project_key()
        repository = input("Enter repository name \n")
        print(
            calling.bitbucket.create_repo(project_key,
                                          repository,
                                          forkable=False,
                                          is_private=True))
        input("press any key to continue")
        main.menu()
    elif task_input == "3":
        # Get branches from repo
        project = calling.project_key()
        repository = input("Enter repository name \n")
        limit = input("Enter limit \n")
        print(
            calling.bitbucket.get_branches(project,
                                           repository,
                                           filter='',
                                           limit=limit,
                                           details=True))
        input("press any key to continue")
        main.menu()
    elif task_input == "4":
        # Creates a branch using the information provided in the request.
        project_key = calling.project_key()
        repository = input("Enter repository name \n")
        name = input("Enter name of your branch \n")
        start_point = input("Enter start point \n")
        message = input("Enter message \n")
        print(
            calling.bitbucket.create_branch(project_key, repository, name,
                                            start_point, message))
        input("press any key to continue")
        main.menu()
    elif task_input == "5":
        # Delete branch from related repo
        project_key = calling.project_key()
        repository = input("Enter repository name \n")
        name = input("Enter name of your branch \n")
        end_point = input("Enter end point \n")
        print(
            calling.bitbucket.delete_branch(project_key, repository, name,
                                            end_point))
        input("press any key to continue")
        main.menu()
    elif task_input == "6":
        # Get pull requests
        project = calling.project_key()
        repository = input("Enter repository name \n")
        print(
            calling.bitbucket.get_pull_requests(project,
                                                repository,
                                                state='OPEN',
                                                order='newest',
                                                limit=100,
                                                start=0))
        input("press any key to continue")
        main.menu()
    elif task_input == "7":
        # Get pull request activities
        project = calling.project_key()
        repository = input("Enter repository name \n")
        pull_request_id = input("Enter pull request id \n")
        print(
            calling.bitbucket.get_pull_requests_activities(
                project, repository, pull_request_id))
        input("press any key to continue")
        main.menu()
    elif task_input == "8":
        # Get pull request changes
        project = calling.project_key()
        repository = input("Enter repository name \n")
        pull_request_id = input("Enter pull request id \n")
        print(
            calling.bitbucket.get_pull_requests_changes(
                project, repository, pull_request_id))
        input("press any key to continue")
        main.menu()
    elif task_input == "9":
        # Get pull request commits
        project = calling.project_key()
        repository = input("Enter repository name \n")
        pull_request_id = input("Enter pull request id \n")
        print(
            calling.bitbucket.get_pull_requests_commits(
                project, repository, pull_request_id))
        input("press any key to continue")
        main.menu()
    elif task_input == "10":
        # Add comment into pull request
        project = calling.project_key()
        repository = input("Enter repository name \n")
        pull_request_id = input("Enter pull request id \n")
        text = input("Enter text \n")
        print(
            calling.bitbucket.add_pull_request_comment(project, repository,
                                                       pull_request_id, text))
        input("press any key to continue")
        main.menu()
    elif task_input == "11":
        # Get tags for related repo
        project = calling.project_key()
        repository = input("Enter repository name \n")
        print(
            calling.bitbucket.get_tags(project,
                                       repository,
                                       filter='',
                                       limit=99999))
        input("press any key to continue")
        main.menu()
    elif task_input == "12":
        # Get project tags
        project = calling.project_key()
        repository = input("Enter repository name \n")
        tag_name = input("Enter tag name id \n")
        print(calling.bitbucket.get_project_tags(project, repository,
                                                 tag_name))
        input("press any key to continue")
        main.menu()
    elif task_input == "13":
        # Set tag
        project = calling.project_key()
        repository = input("Enter repository name \n")
        commit_revision = input("Enter commit revision \n")
        tag_name = input("Enter tag name id \n")
        print(
            calling.bitbucket.set_tag(project,
                                      repository,
                                      tag_name,
                                      commit_revision,
                                      description=None))
        input("press any key to continue")
        main.menu()
    elif task_input == "14":
        # Delete tag
        project = calling.project_key()
        repository = input("Enter repository name \n")
        tag_name = input("Enter tag name id \n")
        print(calling.bitbucket.delete_tag(project, repository, tag_name))
        input("press any key to continue")
        main.menu()
    elif task_input == "15":
        # Get diff
        project = calling.project_key()
        repository = input("Enter repository name \n")
        path = input("Enter path \n")
        hash_oldest = input("Enter hash oldest \n")
        hash_newest = input("Enter hash newest \n")
        print(
            calling.bitbucket.get_diff(project, repository, path, hash_oldest,
                                       hash_newest))
        input("press any key to continue")
        main.menu()
    elif task_input == "16":
        # Get commit list from repo
        project = calling.project_key()
        repository = input("Enter repository name \n")
        hash_oldest = input("Enter hash oldest \n")
        hash_newest = input("Enter hash newest \n")
        print(
            calling.bitbucket.get_commits(project,
                                          repository,
                                          hash_oldest,
                                          hash_newest,
                                          limit=99999))
        input("press any key to continue")
        main.menu()
    elif task_input == "17":
        # Get change log between 2 refs
        project = calling.project_key()
        repository = input("Enter repository name \n")
        ref_from = input("Enter ref from \n")
        ref_to = input("Enter ref to \n")
        print(
            calling.bitbucket.get_changelog(project,
                                            repository,
                                            ref_from,
                                            ref_to,
                                            limit=99999))
        input("press any key to continue")
        main.menu()
    elif task_input == "18":
        # Get raw content of the file from repo
        project = calling.project_key()
        repository = input("Enter repository name \n")
        filename = input("Enter filename \n")
        print(
            calling.bitbucket.get_content_of_file(project,
                                                  repository,
                                                  filename,
                                                  at=None,
                                                  markup=None))
        input("press any key to continue")
        main.menu()
    elif task_input == "19":
        os.system("cls")
        main.menu()
    else:
        manage_code()