当前位置: 首页>>代码示例>>Python>>正文


Python commit.Commit类代码示例

本文整理汇总了Python中commit.Commit的典型用法代码示例。如果您正苦于以下问题:Python Commit类的具体用法?Python Commit怎么用?Python Commit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Commit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find

	def find(query, components):
		conn = DB.getConn()
		c = conn.cursor()
		
		c.execute(query, components)
                commitrows = c.fetchall()
                commitfiles = []

                if commitrows:
                        allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])

                        #This is poor practice, but we assured ourselves the value is composed only of ints first
                        DB.execute(c, "SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
                        commitfiles = c.fetchall()

                        DB.execute(c, "SELECT * from " + DB.commitkeyword._table + " WHERE commitid IN (" + allcommitids + ")")
                        commitkeywords = c.fetchall()

                commits = []
                for i in commitrows:
                        r = Repo()
                        r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2],
                                i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])

                        files = [file[DB.commitfile.file] for file in commitfiles
                                if file[DB.commitfile.commitid] == i[DB.commit.id]]
                        keywords = [keyword[DB.commitkeyword.keyword] for keyword in commitkeywords
                                    if keyword[DB.commitkeyword.commitid] == i[DB.commit.id]]

                        c = Commit()
                        c.loadFromDatabase(r, i, files, keywords)

                        commits.append(c)

                return commits
开发者ID:deepcell,项目名称:code-audit-feed,代码行数:35,代码来源:databaseQueries.py

示例2: parse_commit

 def parse_commit(self, raw_commit):
     commit_lines = raw_commit.split('\n')
     h, ae = commit_lines.pop(0).split('\t')
     commit = Commit(h, ae)
     for commit_line in commit_lines:
         insertions, deletions, path = commit_line.split('\t')
         commit.add_diffstat(insertions, deletions, path)
     return commit
开发者ID:sangheestyle,项目名称:analyze_repo,代码行数:8,代码来源:log_stat.py

示例3: commits

    def commits(self, start='master', path='', max_count=10, skip=0):
        """
        A list of Commit objects representing the history of a given ref/commit

        ``start``
            is the branch/commit name (default 'master')

         ``path``
            is an optional path to limit the returned commits to
            Commits that do not contain that path will not be returned.

         ``max_count``
            is the maximum number of commits to return (default 10)

          ``skip``
            is the number of commits to skip (default 0) which will effectively
            move your commit-window by the given number.

        Returns
            ``git.Commit[]``
        """
        options = {'max_count': max_count,
                   'skip': skip}

        return Commit.find_all(self, start, path, **options)
开发者ID:dvdotsenko,项目名称:ges,代码行数:25,代码来源:repo.py

示例4: findByKeywords

	def findByKeywords(keywords):
		conn = DB.getConn()
		c = conn.cursor()
		
		getcommitsSQL = "SELECT c.*, r.* " + \
				"FROM " + DB.commit._table + " c " + \
				"INNER JOIN " + DB.repo._table + " r " + \
				"	ON r.id = c.repoid "
		
		whereClause = " 1=1 "
		components = []
		if keywords:
			keywordsTree = KeywordsParser(keywords)
			getcommitsSQL += "LEFT OUTER JOIN " + DB.commitkeyword._table + " ck " + \
							 "	ON c.id = ck.commitid "
			whereClause, components = keywordsTree.getWhereClause("ck.keyword", "r.tagname", "r.maturity")
		
		getcommitsSQL += "WHERE " + whereClause
		getcommitsSQL += "ORDER BY c.date DESC "
		
		c.execute(getcommitsSQL, components)
		commitrows = c.fetchall()
		commitfiles = []
		
		if commitrows:
			allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])
		
			#This is poor practice, but we assured ourselves the value is composed only of ints first
			c.execute("SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
			commitfiles = c.fetchall()

		commits = []
		for i in commitrows:
			r = Repo()
			r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2], 
				i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])
			
			files = [file[DB.commitfile.file] for file in commitfiles 
				if file[DB.commitfile.commitid] == i[DB.commit.id]]
			
			c = Commit()
			c.loadFromDatabase(r, i, files)
			
			commits.append(c)

		return commits
开发者ID:sirvaliance,项目名称:code-audit-feed,代码行数:46,代码来源:databaseQueries.py

示例5: __getitem__

 def __getitem__(self, key):
     if isinstance(key, slice):
         li = []
         step = key.step
         if step:
             for idx, c in enumerate(Commit.get_raw_commits(self,
                                                       key.start,
                                                       key.stop)):
                 if not (idx % step):
                     li.append(Commit(raw_commit=c, obj=self))
         else:
             for c in Commit.get_raw_commits(self, key.start, key.stop):
                 li.append(Commit(raw_commit=c, obj=self))
         return li
     elif isinstance(key, str):
         return Commit(key, obj=self)
     else:
         raise TypeError(str(type(key)) + " " + str(key))
开发者ID:blix,项目名称:pyrite,代码行数:18,代码来源:repository.py

示例6: getCommits

def getCommits(repo, startdate, enddate):
	end_rev = pysvn.Revision(pysvn.opt_revision_kind.date, enddate)
	start_rev = pysvn.Revision(pysvn.opt_revision_kind.date, startdate)
	
	c = pysvn.Client()

	commits = []
	msgs = c.log(repo.url, revision_start=start_rev, revision_end=end_rev, discover_changed_paths=True)
	msgs.reverse() 
	for m in msgs:
		date = m.data['revprops']['svn:date']
		message = m.data['message']
		paths = [p.path for p in m.data['changed_paths']]

		c = Commit()
		c.loadFromSource(repo, message, date, paths, m.data['revision'].number)
		commits.append(c)
	return commits
开发者ID:sirvaliance,项目名称:code-audit-feed,代码行数:18,代码来源:svnpuller.py

示例7: commit_diff

    def commit_diff(self, commit):
        """
        The commit diff for the given commit
          ``commit`` is the commit name/id

        Returns
            ``git.Diff[]``
        """
        return Commit.diff(self, commit)
开发者ID:dvdotsenko,项目名称:ges,代码行数:9,代码来源:repo.py

示例8: getCommits

def getCommits(repo, startdate, enddate):
    localfolder = urlToFolder(repo.url)
    differ = gdiff.diff_match_patch()

    repoloc = "git-repos/" + localfolder + "/"
    if os.path.exists(repoloc):
        c = pygit.Repo(repoloc)
    else:
        os.makedirs(repoloc)
        c = pygit.Repo.init(repoloc)
        c.create_remote("origin", repo.url)

    c.remotes.origin.fetch()
    c.remotes.origin.pull("master")

    commits = []
    msgs = c.iter_commits(since=unixToGitDateFormat(startdate))
    for m in msgs:
        if m.committed_date > enddate:
            continue

        alldiffs = []
        for d in m.diff("HEAD~1").iter_change_type("M"):  # Changed
            left = d.a_blob.data_stream.read()
            right = d.b_blob.data_stream.read()
            diffs = differ.diff_main(left, right)
            if diffs:
                differ.diff_cleanupSemantic(diffs)

            for d in diffs:
                if d[0] != 0 and d[1].strip():
                    alldiffs.append(d)

        for d in m.diff().iter_change_type("A"):  # Added
            pass
        for d in m.diff().iter_change_type("D"):  # Deleted
            pass
        for d in m.diff().iter_change_type("R"):  # Renamed
            pass

        c = Commit()
        c.loadFromSource(repo, m.message, m.committed_date, m.stats.files.keys(), m.__str__(), alldiffs)
        commits.append(c)
    return commits
开发者ID:deepcell,项目名称:code-audit-feed,代码行数:44,代码来源:gitpuller.py

示例9: findByIDs

	def findByIDs(project, uniqueid):
		conn = DB.getConn()
		c = conn.cursor()
		
		getcommitsSQL = "SELECT c.*, r.* " + \
				"FROM " + DB.commit._table + " c " + \
				"INNER JOIN " + DB.repo._table + " r " + \
				"	ON r.id = c.repoid "
		
		whereClause = " 1=1 "
		components = []
		if project and uniqueid:
			whereClause += "AND r.tagname = %s AND c.uniqueid = %s "
			components = [project, uniqueid]
		
		getcommitsSQL += "WHERE " + whereClause
		getcommitsSQL += "ORDER BY c.date DESC "
		
		DB.execute(c, getcommitsSQL, components)
		commitrows = c.fetchall()
		commitfiles = []
		
		if commitrows:
			allcommitids = ",".join([str(int(commit[0])) for commit in commitrows])
		
			#This is poor practice, but we assured ourselves the value is composed only of ints first
			DB.execute(c, "SELECT * from " + DB.commitfile._table + " WHERE commitid IN (" + allcommitids + ")")
			commitfiles = c.fetchall()

		commits = []
		for i in commitrows:
			r = Repo()
			r.loadFromValues(i[DB.commit._numColumns + 0], i[DB.commit._numColumns + 1], i[DB.commit._numColumns + 2], 
				i[DB.commit._numColumns + 3], i[DB.commit._numColumns + 4], i[DB.commit._numColumns + 5])
			
			files = [file[DB.commitfile.file] for file in commitfiles 
				if file[DB.commitfile.commitid] == i[DB.commit.id]]
			
			c = Commit()
			c.loadFromDatabase(r, i, files)
			
			commits.append(c)

		return commits
开发者ID:sirvaliance,项目名称:code-audit-feed,代码行数:44,代码来源:databaseQueries.py

示例10: commit_count

    def commit_count(self, start = 'master'):
        """
        The number of commits reachable by the given branch/commit

        ``start``
            is the branch/commit name (default 'master')

        Returns
            int
        """
        return Commit.count(self, start)
开发者ID:directeur,项目名称:git-python,代码行数:11,代码来源:repo.py

示例11: parse

 def parse(cls, json_as_text):
     l = []
     data = json.loads(json_as_text)
     for item in data:
         l.append({
             'uri': item['uri'],
             'name': item['name'],
             'activity': item['activity'],
             'latest': Commit.from_dict(item['latest'])
         })
     return l
开发者ID:MartinEden,项目名称:humdrum,代码行数:11,代码来源:repositories.py

示例12: commit_deltas_from

    def commit_deltas_from(self, other_repo, ref='master', other_ref='master'):
        """
        Returns a list of commits that is in ``other_repo`` but not in self

        Returns
            git.Commit[]
        """
        repo_refs = self.git.rev_list(ref, '--').strip().splitlines()
        other_repo_refs = other_repo.git.rev_list(other_ref, '--').strip().splitlines()

        diff_refs = list(set(other_repo_refs) - set(repo_refs))
        return map(lambda ref: Commit.find_all(other_repo, ref, max_count=1)[0], diff_refs)
开发者ID:dvdotsenko,项目名称:ges,代码行数:12,代码来源:repo.py

示例13: getCommits

def getCommits(repo, startdate, enddate):
	localfolder = urlToFolder(repo.url)

	repoloc = 'git-repos/' + localfolder + '/'
	if os.path.exists(repoloc):
		c = pygit.Repo(repoloc)
	else:
		os.makedirs(repoloc)
		c = pygit.Repo.init(repoloc)
		c.create_remote('origin', repo.url)

	c.remotes.origin.fetch()
	c.remotes.origin.pull('master')

	commits = []
	msgs = c.iter_commits(since=unixToGitDateFormat(startdate))
	for m in msgs:
		if m.committed_date > enddate: continue
		c = Commit()
		c.loadFromSource(repo, m.message, m.committed_date, m.stats.files.keys(), m.__str__())
		commits.append(c)
	return commits
开发者ID:sirvaliance,项目名称:code-audit-feed,代码行数:22,代码来源:gitpuller.py

示例14: log

    def log(self, commit='master', path=None, **kwargs):
        """
        The commit log for a treeish

        Returns
            ``git.Commit[]``
        """
        options = {'pretty': 'raw'}
        options.update(kwargs)
        arg = [commit, '--']
        if path:
            arg.append(path)
        commits = self.git.log(*arg, **options)
        return Commit.list_from_string(self, commits)
开发者ID:2flcastro,项目名称:ka-lite,代码行数:14,代码来源:repo.py

示例15: commit_count

    def commit_count(self, start='master', path=''):
        """
        The number of commits reachable by the given branch/commit

        ``start``
            is the branch/commit name (default 'master')

        ``path``
            is an optinal path

        Returns
            int
        """
        return Commit.count(self, start, path)
开发者ID:2flcastro,项目名称:ka-lite,代码行数:14,代码来源:repo.py


注:本文中的commit.Commit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。