예제 #1
0
def _main():

    log = logging.getLogger(name="dls_ade")
    usermsg = logging.getLogger(name="usermessages")

    parser = make_parser()
    args = parser.parse_args()

    log.info(json.dumps({'CLI': sys.argv, 'options_args': vars(args)}))

    if args.module_name == "":
        answer = input("Would you like to checkout the whole " + args.area +
                       " area? This may take some time. Enter Y or N: ")
        if answer.upper() != "Y":
            return

    check_technical_area(args.area, args.module_name)

    module = args.module_name

    server = Server()

    if module == "":
        # Set source to area folder
        source = server.dev_area_path(args.area)
    else:
        # Set source to module in area folder
        source = server.dev_module_path(module, args.area)

    if module == "":
        usermsg.info("Checking out entire {} area".format(args.area))
        server.clone_multi(source)
    elif module.endswith('/') and args.area == 'ioc':
        usermsg.info("Checking out {} technical area...".format(module))

        source = server.dev_group_path(module, args.area)

        server.clone_multi(source)
    else:
        usermsg.info("Checking out {module} from {area}".format(
            module=module, area=args.area))
        vcs = server.clone(source, module)

        if args.branch:
            # Get branches list
            branches = vcs_git.list_remote_branches(vcs.repo)
            if args.branch in branches:
                vcs_git.checkout_remote_branch(args.branch, vcs.repo)
            else:
                # Invalid branch name, print branches list and exit
                usermsg.info("Branch '{branch}' does not exist in {source}. "
                             "Leaving clone on default branch. "
                             "Branch List: {branchlist}".format(
                                 branch=args.branch,
                                 source=source,
                                 branchlist=str(branches)))

        vcs_git.add_remotes(vcs.repo, module)
예제 #2
0
    def clone_server_repo(self):
        """Clone the server_repo_path to a temp dir and return the path.

        If a branch name is set, then the remote branch will be checked out.

        Raises:
            VCSGitError: From vcs_git.temp_clone()
        """
        logging.debug("Cloning the server repository to temporary directory.")
        repo = self.server.temp_clone(self._server_repo_path).repo

        if self._branch_name:
            vcs_git.checkout_remote_branch(self._branch_name, repo)

        self._server_repo_clone_path = repo.working_tree_dir
        logging.debug("The cloned directory is: " +
                      self._server_repo_clone_path)
예제 #3
0
    def clone_server_repo(self):
        """Clone the server_repo_path to a temp dir and return the path.

        If a branch name is set, then the remote branch will be checked out.

        Raises:
            VCSGitError: From vcs_git.temp_clone()
        """
        logging.debug("Cloning the server repository to temporary directory.")
        repo = vcs_git.temp_clone(self._server_repo_path)

        if self._branch_name:
            vcs_git.checkout_remote_branch(self._branch_name, repo)

        self._server_repo_clone_path = repo.working_tree_dir
        logging.debug("The cloned directory is: " +
                      self._server_repo_clone_path)
예제 #4
0
def main():

    parser = make_parser()
    args = parser.parse_args()

    if args.module_name == "":
        answer = raw_input("Would you like to checkout the whole " +
                           args.area + " area? This may take some time. Enter Y or N: ")
        if answer.upper() != "Y":
            return

    check_technical_area(args.area, args.module_name)

    module = args.module_name

    if module == "":
        # Set source to area folder
        source = pathf.dev_area_path(args.area)
    else:
        # Set source to module in area folder
        source = pathf.dev_module_path(module, args.area)

    if module == "":
        print("Checking out entire " + args.area + " area...\n")
        vcs_git.clone_multi(source)
    elif module.endswith('/') and args.area == 'ioc':
        print("Checking out " + module + " technical area...")
        vcs_git.clone_multi(source)
    else:
        print("Checking out " + module + " from " + args.area + " area...")
        repo = vcs_git.clone(source, module)

        if args.branch:
            # Get branches list
            branches = vcs_git.list_remote_branches(repo)
            if args.branch in branches:
                vcs_git.checkout_remote_branch(args.branch, repo)
            else:
                # Invalid branch name, print branches list and exit
                print("Branch '" + args.branch + "' does not exist in " + source +
                      "\nBranch List:\n")
                for entry in branches:
                    print(entry)