Ejemplo n.º 1
0
def main():
    # parse arguments
    args = parse_command_line(sys.argv[1:])
    if args.publish:
        if args.git_credential:
            repo_operator = RepoOperator(args.git_credential)
        else:
            print "Error occurs when get crendtail in update submodule"
            sys.exit(1)
    else:
        repo_operator = RepoOperator(args.git_credential)
    if os.path.isdir(args.build_dir):
        for filename in os.listdir(args.build_dir):
            try:
                repo_dir = os.path.join(args.build_dir, filename)
                submodules_list = subModulesExist(repo_dir, repo_operator)
                if submodules_list is None:
                    continue
                #git pull is used to get the lastest code to make sure push successfully
                test_info = repo_operator.git_pull(repo_dir, "origin",
                                                   "master")
                revert_commit_for_submodules_update(repo_dir, repo_operator,
                                                    args.version)
                if args.publish:
                    print "start to publish  revert update submodule in {0}".format(
                        repo_dir)
                    commit_message = "revert update submodule for new commit {}".format(
                        args.version)
                    repo_operator.push_repo_changes(repo_dir, commit_message)
            except Exception, e:
                print "Failed to revert update submodule of {0} due to {1}".format(
                    filename, e)
                sys.exit(1)
Ejemplo n.º 2
0
    def __init__(self,
                 source,
                 dest,
                 branch,
                 builddir,
                 git_credentials,
                 force=False,
                 jobs=1):
        """
        Generate a new manifest for new branch according to a source manifest file.

        _source_manifest_file: the path of source manifest
        _dest_manifest_file: the path of new manifest
        _new_branch: the new branch name
        _force: overwrite the destination if it exists.
        _git_credentials: url, credentials pair for the access to github repos.
        _builddir: the destination for checked out repositories.
        _jobs: number of parallel jobs to run. The number is related to the compute architecture, multi-core processors...
        :return: None
        """
        self._source_manifest_file = source
        self._dest_manifest_file = dest
        self._new_branch = branch
        self._git_credentials = git_credentials
        self._manifest = None
        self._force = force
        self._builddir = builddir
        self._jobs = jobs
        self.initiate_manifest()
        self.repo_operator = RepoOperator(git_credentials)
        self.check_builddir()
Ejemplo n.º 3
0
    def __init__(self,
                 manifest_path,
                 builddir,
                 force=False,
                 git_credentials=None,
                 jobs=1,
                 actions=[],
                 branch_name=None,
                 tag_name=None):
        """
        __force - Overwrite a directory if it exists
        __git_credential - url, credentials pair for the access to github repos
        __manifest - Repository manifest contents
        __builddir - Destination for checked out repositories
        __jobs - Number of parallel jobs to run
        __actions -Supported actions
        :return:
        """
        self._force = force
        self._git_credentials = git_credentials
        self._builddir = builddir
        self._manifest = None
        self.handle_manifest(manifest_path)
        self._jobs = jobs
        self.actions = []
        for action in actions:
            self.add_action(action)

        self._branch_name = branch_name
        self._tag_name = tag_name
        self.repo_operator = RepoOperator(self._git_credentials)
Ejemplo n.º 4
0
def main():
    # parse arguments
    args = parse_command_line(sys.argv[1:])
    if args.publish:
        if args.git_credential:
            repo_operator = RepoOperator(args.git_credential)
        else:
            print "If you want to publish the updated changelog, please specify the git-credential. Exiting now..."
            sys.exit(1)

    if os.path.isdir(args.build_dir):
        for filename in os.listdir(args.build_dir):
            try:
                repo_dir = os.path.join(args.build_dir, filename)
                updater = ChangelogUpdater(repo_dir, args.version)
                if updater.update_changelog(message=args.message):
                    if args.publish:
                        commit_message = "update changelog for new release {0}".format(
                            args.version)
                        repo_operator.push_repo_changes(
                            repo_dir, commit_message)
            except Exception, e:
                print "Failed to update changelog of {0} due to {1}".format(
                    filename, e)
                sys.exit(1)
Ejemplo n.º 5
0
 def __init__(self):
     """
     __repo - the repository url being updated in the manifest
     __branch - the branch name associated with __repo
     __sliced_branch - the branch name sliced at any forward slashes
     __commit - The commit id associated with the __repo and __branch that we want to update
     __manifest_repository_url - the repository url the points to the collection of manifest files
     __manifest_file - the desired manifest file to update which resides in __manifest_repository_url
     __cleanup_directories - the path/name of directories created are appended here for cleanup in task_cleanup
     __git_credentials - url, credentials pair for the access to github repos
     quiet - used for testing to minimize text written to a terminal
     repo_operator - Class instance of RepoOperator
     :return: None
     """
     self.__repo = None
     self.__branch = None
     self.__sliced_branch = None
     self.__commit = None
     self.__manifest_repository_url = None
     self.__manifest_file = None
     self.__cleanup_directories = []
     self.__git_credentials = None
     self.__updated_manifest = None
     self.__dryrun = False
     self.quiet = False
     self.repo_operator = RepoOperator()
Ejemplo n.º 6
0
    def __init__(self,
                 dest,
                 branch,
                 builddir,
                 git_credential=None,
                 force=False,
                 jobs=1):
        """
        Generate a new manifest according to the manifest sample: manifest.json

        _dest_manifest_file: the path of new manifest
        _branch: the branch name
        _force: overwrite the destination if it exists.
        _builddir: the destination for checked out repositories.
        _jobs: number of parallel jobs to run. The number is related to the compute architecture, multi-core processors...
        :return: None
        """
        self._dest_manifest_file = dest
        self._branch = branch
        self._builddir = builddir
        self._force = force
        self._jobs = jobs
        self._manifest = Manifest.instance_of_sample()
        self.repo_operator = RepoOperator(git_credential)
        self.check_builddir()
Ejemplo n.º 7
0
def main():
    # parse arguments
    args = parse_command_line(sys.argv[1:])
    if args.publish:
        if args.git_credential:
            repo_operator = RepoOperator(args.git_credential)
        else:
            print "If you want to publish the updated changelog, please specify the git-credential. Exiting now..."
            sys.exit(1)

    if os.path.isdir(args.build_dir):
        for filename in os.listdir(args.build_dir):
            try:
                repo_dir = os.path.join(args.build_dir, filename)
                changelog_updater = ChangelogUpdater(repo_dir, args.version)
                npm_package_updater = NPMVersionUpdater(repo_dir, args.version)
                package_updated = npm_package_updater.update_package_json()
                changelog_updated = changelog_updater.update_changelog(message = args.message)
                if changelog_updated or package_updated:
                    if args.publish:
                        print "start to push changes in {0}".format(repo_dir)
                        commit_message = "jump version for new release {0}".format(args.version)
                        repo_operator.push_repo_changes(repo_dir, commit_message)
            except Exception,e:
                print "Failed to jump version of {0} due to {1}".format(filename, e)
                sys.exit(1)
Ejemplo n.º 8
0
 def __init__(self, dest, builddir, git_credential=None, force=False, jobs=1):
     self._jenkins_author = config.gitbit_identity["username"]
     self._dest_manifest_file = dest
     self._builddir = builddir
     self._force = force
     self._jobs = jobs
     self._manifest = Manifest.instance_of_sample()
     self.repo_operator = RepoOperator(git_credential)
     self.check_builddir()
Ejemplo n.º 9
0
 def __init__(self, repo_dir, version):
     """
     The module updates debian/changelog under the directory of repository
     _repo_dir: the directory of the repository
     _version: the new version which is going to be updated to changelog
     """
     self._repo_dir = repo_dir
     self._version = version
     self.repo_operator = RepoOperator()
Ejemplo n.º 10
0
def main():
    # parse arguments
    args = parse_command_line(sys.argv[1:])
    try:
        manifest = Manifest(args.manifest)
        manifest.validate_manifest()
    except KeyError as error:
        print "Failed to create a Manifest instance for the manifest file {0} \nERROR:\n{1}"\
              .format(args.manifest, error.message)
        sys.exit(1)

    if args.publish:
        if args.git_credential:
            repo_operator = RepoOperator(args.git_credential)
        else:
            print "Error occurs when get crendtail in update submodule"
            sys.exit(1)
    else:
        repo_operator = RepoOperator(args.git_credential)
    if os.path.isdir(args.build_dir):
        print args.build_dir
        for filename in os.listdir(args.build_dir):
            try:
                repo_dir = os.path.join(args.build_dir, filename)
                repo_operator.submodule_init(repo_dir)
                repo_operator.submodule_update(repo_dir)
                submodules_list = repo_operator.get_current_submodule(repo_dir)
                if len(submodules_list) == 0:
                    continue
                for key in submodules_list:
                    commit_id = get_manifest_commit_id(key, manifest)
                    if commit_id != None:
                        sub_dir = repo_dir + "/" + key
                        repo_operator.checkout_to_commit(sub_dir, commit_id)
                if args.publish:
                    print "start to publish  update submodule in {0}".format(
                        repo_dir)
                    commit_message = "update submodule for new commit {0}".format(
                        args.version)
                    repo_operator.push_repo_changes(repo_dir, commit_message)
            except Exception, e:
                print "Failed to update submodule of {0} due to {1}".format(
                    filename, e)
                sys.exit(1)
Ejemplo n.º 11
0
 def __init__(self, repo_dir):
     """
     This module compute the version of a repository
     The version for candidate release: {release_version}-{build_version}
     The release version is parsed from debian/changelog
     The samll version is consist of the commit hash and commit date of manifest repository
     :return:None
     """
     self._repo_dir = repo_dir
     self.repo_operator = RepoOperator()
     self._repo_name = self.get_repo_name()
Ejemplo n.º 12
0
 def __init__(self, repo_dir):
     """
     This module compute the version of a repository
     The version for candidate release: {big-version}~{version-stage}-{small-version}
     The big version is parsed from debian/changelog
     The version-stage is devel if branch is master; or rc if branch if not master
     The samll version is consist of the commit hash and commit date of manifest repository
     :return:None
     """
     self._repo_dir = repo_dir
     self.repo_operator = RepoOperator()
     self._repo_name = self.get_repo_name()
Ejemplo n.º 13
0
    def __init__(self, manifest_dir, builddir, is_official_release=False):
        """
        Compute the version of each repository under builddir
        and update the debian/control with these versions

        __manifest_repo_dir - The directory of Repository manifest
        __builddir - Destination for checked out repositories
        __is_official_release - True if the official is official release
        :return: None
        """
        self._builddir = builddir
        self._manifest_repo_dir = manifest_dir       
        self._is_official_release = is_official_release

        self.repo_operator = RepoOperator()
Ejemplo n.º 14
0
    def __init__(self, manifest_path, builddir):
        """
        __force - Overwrite a directory if it exists
        __git_credential - url, credentials pair for the access to github repos
        __manifest - Repository manifest contents
        __builddir - Destination for checked out repositories
        __jobs - Number of parallel jobs to run
        __actions -Supported actions
        :return:
        """
        self._force = False
        self._git_credentials = None
        self._builddir = builddir
        self._manifest = None
        self.handle_manifest(manifest_path)
        self._jobs = 1
        self.actions = []

        self.repo_operator = RepoOperator()
Ejemplo n.º 15
0
def main():
    # parse arguments
    args = parse_command_line(sys.argv[1:])
    generator = ManifestGenerator(args.source_manifest,
                                  args.dest_manifest,
                                  args.branch,
                                  args.builddir,
                                  args.git_credentials,
                                  jobs=args.jobs,
                                  force=args.force)
    try:
        generator.update_manifest()
        if args.force:
            generator.set_force(args.force)

        if args.publish:
            if args.git_credentials and args.publish_branch:
                repo_operator = RepoOperator(args.git_credentials)
                commit_message = "add a manifest file for new branch {0}".format(
                    args.branch)
                repo_dir = os.path.dirname(args.dest_manifest)
                repo_operator.checkout_repo_branch(repo_dir,
                                                   args.publish_branch)
                generator.generate_manifest()
                repo_operator.push_repo_changes(repo_dir,
                                                commit_message,
                                                push_all=True)
            else:
                print "Please specify the git-credential and publish-branch if you want to push the new manifest"
                sys.exit(1)
        else:
            generator.generate_manifest()
    except Exception, e:
        traceback.print_exc()
        print "Failed to generate new manifest for {0} due to \n{1}\nExiting now".format(
            args.branch, e)
        sys.exit(1)