Пример #1
0
        def __fetch_from_git(self, module):
            if not os.path.exists(module.fetchto):
                os.mkdir(module.fetchto)

            cur_dir = os.getcwd()
            if module.branch == None:
                module.branch = "master"

            basename = path.url_basename(module.url)
            mod_path = os.path.join(module.fetchto, basename)

            if basename.endswith(".git"):
                basename = basename[:-4] #remove trailing .git

            if module.isfetched:
                update_only = True
            else:
                update_only = False

            if update_only:
                cmd = "(cd {0} && git checkout {1})"
                cmd = cmd.format(mod_path, module.branch)
            else:
                cmd = "(cd {0} && git clone -b {2} {1})"
                cmd = cmd.format(module.fetchto, module.url, module.branch)

            rval = True

            p.vprint(cmd)
            if os.system(cmd) != 0:
                rval = False

            if module.revision and rval:
                os.chdir(mod_path)
                cmd = "git checkout " + module.revision
                p.vprint(cmd)
                if os.system(cmd) != 0:
                    rval = False
                os.chdir(cur_dir)

            module.isfetched = True
            module.path = mod_path
            return rval
Пример #2
0
        def __fetch_from_git(self, module):
            if not os.path.exists(module.fetchto):
                os.mkdir(module.fetchto)

            cur_dir = os.getcwd()
            if module.branch == None:
                module.branch = "master"

            basename = path.url_basename(module.url)
            mod_path = os.path.join(module.fetchto, basename)

            if basename.endswith(".git"):
                basename = basename[:-4]  #remove trailing .git

            if module.isfetched:
                update_only = True
            else:
                update_only = False

            if update_only:
                cmd = "(cd {0} && git checkout {1})"
                cmd = cmd.format(mod_path, module.branch)
            else:
                cmd = "(cd {0} && git clone -b {2} {1})"
                cmd = cmd.format(module.fetchto, module.url, module.branch)

            rval = True

            p.vprint(cmd)
            if os.system(cmd) != 0:
                rval = False

            if module.revision and rval:
                os.chdir(mod_path)
                cmd = "git checkout " + module.revision
                p.vprint(cmd)
                if os.system(cmd) != 0:
                    rval = False
                os.chdir(cur_dir)

            module.isfetched = True
            module.path = mod_path
            return rval
Пример #3
0
 def basename(self):
     import path
     if self.source == "svn":
         return path.svn_basename(self.url)
     else:
         return path.url_basename(self.url)
Пример #4
0
 def basename(self):
     import path
     if self.source == "svn":
         return path.svn_basename(self.url)
     else:
         return path.url_basename(self.url)