コード例 #1
0
    def __getNumCommitEachStatusByDateRange(self, commitDates):
        numCommitEachStatus = {key: 0 for key in Utility.STATUSES}
        hasRecordedDateDict = {}

        if "numCommits" in commitDates and commitDates['numCommits'] == 0:
            return numCommitEachStatus

        for commitNdx, commitDate in enumerate(commitDates):
            for key, timeList in self.dateRangeEachState.items():
                for oneDateRange in self.__formatTimeList(timeList):
                    if commitNdx not in hasRecordedDateDict:
                        if self.END_TIME_STR not in oneDateRange and \
                                GitOperations.compareGitDates(commitDate,
                                                              oneDateRange[self.START_TIME_STR]):
                            # Example: a resolved issue that still have commits
                            numCommitEachStatus[key] += 1
                            hasRecordedDateDict[commitNdx] = True
                        elif self.END_TIME_STR in oneDateRange and \
                                GitOperations.compareGitDates(oneDateRange[self.END_TIME_STR], commitDate):
                            numCommitEachStatus[key] += 1
                            hasRecordedDateDict[commitNdx] = True
                        elif self.START_TIME_STR not in oneDateRange and \
                                GitOperations.compareGitDates(oneDateRange[self.END_TIME_STR], commitDate):
                            numCommitEachStatus[key] += 1
                            hasRecordedDateDict[commitNdx] = True

        return numCommitEachStatus
コード例 #2
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def __init__(self, gitCloneURL, localRepo, gitProjectName):
     print("initializing gitProjectName = ", gitProjectName)
     print("initializing gitCloneURL = ", gitCloneURL)
     print("initializing localRepo = ", localRepo)
     GitOperations.cloneAndPull(
         localRepo, Utility.getGoodWindowFileName(gitProjectName),
         gitCloneURL)
     self.gitCloneURL = gitCloneURL
     self.localRepo = localRepo
     self.gitProjectName = gitProjectName
     self.PULL_REQUESTS_BY_PAGE = self._Git_API_URL.format(
         gitProjectName, "all")
     self.CLOSED_PULL_REQUEST_BY_PAGE = self._Git_API_URL.format(
         gitProjectName, "closed")
コード例 #3
0
def __getValidGitRepo(eachRepo):
    print("Validating repo's url = ", eachRepo)
    gitUrlByRegex = re.findall("(:?.*)\/(.*).git", eachRepo)
    truncatedGitUrl = re.findall("(:?git:)(.*)", eachRepo)
    print("gitUrlByRegx = ", gitUrlByRegex)
    print("truncatedGitUrl = ", truncatedGitUrl)
    if len(truncatedGitUrl) > 0:
        # Valid git clone url, such as git://.*.
        return eachRepo
    elif len(gitUrlByRegex) > 0 and "git" in gitUrlByRegex[0][0]:
        # git clone url with https, such as https://.*.git
        # For example: https://git-wip-us.apache.org/repos/asf?p=ambari.git
        # gitUrlByRegex constains a array of tuple. gitUrlByRegex[0][0] = the originial url
        #                                           gitUrlByRegex[0][1] = the parsed git repo's name
        return _APACHE_GITHUB_GIT_CLONE.format(gitUrlByRegex[0][1])
    elif eachRepo.find("svn") > 0:
        # svn mirror, such as http://svn.apache.org/.*/trunk/, and "http://svn.apache.org/.*/"
        svnNameInASF = re.findall(".*/asf/(.*)(?:/)", eachRepo)
        svnNameInTrunk = re.findall("(?:.*)\/(.*)\/(?:trunk)", eachRepo)
        svnName = svnNameInASF[
            0] if svnNameInASF else svnNameInTrunk[0] if svnNameInTrunk else ""
        if svnName != "" and GitOperations.isValidGitCloneURL(
                _APACHE_GITHUB.format(svnName)):
            return _APACHE_GITHUB_GIT_CLONE.format(svnName)
        return False
    else:
        return False
コード例 #4
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def getNumberBranches(self):
     numBranch = None
     if self.__hasMasterBranch() == 0:
         return 0
     else:
         numBranch = GitOperations.executeGitShellCommand(
             self.localRepo, ["git branch -a | grep \'remote\' | wc -l"])
         return int(re.sub(r'\s+', '', numBranch))
コード例 #5
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def getUniqueDevelopers(self, reqName):
     developers = GitOperations.getGitLogInfo(
         self.localRepo, reqName, self.__getGitDeveloperForThisReq)
     developerSet = set()
     print("developers = ", developers)
     for dev in developers["formattedDevelopers"]:
         developerSet.add(dev)
     return developerSet
コード例 #6
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def getPercentageByH4(self):
     mergedByH4 = []
     for pr in self.__getAllUnmergedAndClosedPullRequests():
         out = GitOperations.executeGitShellCommand(
             self.localRepo,
             ["git rev-list -1 --before=" + pr["closed_at"] + " master"])
         if self.__hasMasterBranch() != 0 and self.__hasMergedKeyword(out):
             mergedByH4.append(pr)
     return len(mergedByH4) / len(self.allUnmergedAndClosedPullRequests)
コード例 #7
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def getPortionOfCommitsThroughMasterBranch(self):
     totalNumCommitOnMaster = int(
         GitOperations.executeGitShellCommand(
             self.localRepo, ["git rev-list --count master"]))
     allShaOnMaster = GitOperations.executeGitShellCommand(
         self.localRepo, ["git log --pretty=format:'%H'"]).split("\n")
     totalNumCommitThroughMaster = 0
     for sha in allShaOnMaster:
         print("sha = ", sha)
         if self.__isCommittedThroughMaster(sha):
             totalNumCommitThroughMaster += 1
         else:
             print("not committed through master = ", sha)
     if self.__checkIfTheLatestCommitCommittedThroughMaster():
         totalNumCommitOnMaster += 1
     print("totalNumCommitOnMaster = ", totalNumCommitOnMaster)
     print("totalNumCommitThroughMaster = ", totalNumCommitThroughMaster)
     return (totalNumCommitOnMaster, totalNumCommitThroughMaster)
コード例 #8
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def getPercentageByH1(self):
     h1Merged = []
     for pr in self.__getAllUnmergedAndClosedPullRequests():
         hasAddedThisPr = False
         commitDict = Utility.convertDictStringToDict(
             GitOperations.requestByGitAPIWithAuth(pr["commits_url"]))
         for commit in commitDict:
             if self.__isInMasterBranch(
                     commit["sha"]) and not hasAddedThisPr:
                 h1Merged.append(pr)
                 hasAddedThisPr = True
     return len(h1Merged) / len(self.allUnmergedAndClosedPullRequests)
コード例 #9
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
    def __getAllClosedPullRequestByPaging(self):
        page = 0
        allPullRequestDict = []
        while True:
            pullRequestsOnePageDict = Utility.convertDictStringToDict(
                GitOperations.requestByGitAPIWithAuth(
                    self.CLOSED_PULL_REQUEST_BY_PAGE + str(page)))
            if len(pullRequestsOnePageDict) == 0:
                break
            else:
                allPullRequestDict += pullRequestsOnePageDict
            page += 1

        return allPullRequestDict
コード例 #10
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def __isCommittedThroughMaster(self, sha):
     consoleOutput = GitOperations.executeGitShellCommand(
         self.localRepo, ["git when-merged -l {}".format(sha)])
     isDirectCommit = 0
     isMergedMaster = 0
     if consoleOutput != None:
         isDirectCommit = len(
             re.findall(
                 "(master                      Commit is directly on this branch.)",
                 consoleOutput)) > 0
         isMergedMaster = len(
             re.findall("(Merge branch 'master')", consoleOutput)) > 0
         print("isDirectCommit = ", isDirectCommit)
         print("isMergedMaster = ", isMergedMaster)
     return isDirectCommit or isMergedMaster
コード例 #11
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def getPercentageByH3(self):
     commitCount = 0
     h3Merged = []
     for pr in self.__getAllUnmergedAndClosedPullRequests():
         hasAddedThisPr = False
         commitDict = Utility.convertDictStringToDict(
             GitOperations.requestByGitAPIWithAuth(pr["commits_url"]))
         for commit in commitDict:
             if (self.__isInMasterBranch(commit["sha"])
                     and self.__hasMergedKeyword(commit["sha"])
                     and not hasAddedThisPr):
                 h3Merged.append(pr)
                 hasAddedThisPr = False
             if commitCount == 2:
                 break
     return len(h3Merged) / len(self.allUnmergedAndClosedPullRequests)
コード例 #12
0
ファイル: ProjectApache.py プロジェクト: dfalessi/CCP-changes
    def getPortionOfCommitsWithUnassignedTask(self):
        totalNumCommits = 0
        numUnassignedTaskWithCommits = 0

        unassignedIssues = JiraQuery.getUnassignedIssues(
            JIRA({'server': 'https://issues.apache.org/jira'}),
            self.jiraApache.jiraProjectName)

        for localRepo in self.localRepos:
            numCommits = GitOperations.executeGitShellCommand(
                localRepo, ["git log --all --pretty=format:'%H' | wc -l"])
            totalNumCommits += int(numCommits.replace(" ", ""))

        for localRepo in self.localRepos:
            repo = git.Repo(localRepo)
            for issue in unassignedIssues:
                logInfo = repo.git.log("--all", "-i", "--grep=" + issue)
                if logInfo != "":
                    numUnassignedTaskWithCommits += 1
        print("numUnassignedTaskWithCommits = ", numUnassignedTaskWithCommits)
        print("totalNumCommits = ", totalNumCommits)
        return round(numUnassignedTaskWithCommits / totalNumCommits, 2)
コード例 #13
0
ファイル: RandomTest.py プロジェクト: dfalessi/CCP-changes
def totalNumCommitsOnAllBrances(localRepo):
    allSha = GitOperations.executeGitShellCommand(
        localRepo, ["git log --all --pretty=format:'%H' | wc -l"])
    return int(allSha.replace(" ", "")) + 1
コード例 #14
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def __hasMasterBranch(self):
     numBranch = GitOperations.executeGitShellCommand(
         self.localRepo, ["git branch -a | grep \'master\' | wc -l"])
     return int(re.sub(r'\s+', '', numBranch))
コード例 #15
0
 def getNumCommitDuringEachStatus(self, localRepo):
     self.__getHistoryItems(self.__initDateRangeEachStatus)
     return self.__getNumCommitEachStatusByDateRange(
         GitOperations.getCommitsDatesForThisReq(localRepo, self.reqName))
コード例 #16
0
ファイル: RandomTest.py プロジェクト: dfalessi/CCP-changes
                    self.currentStatus = item.toString
        return result


# oneIssue = Issue("TIKA-1699",
#                 JIRA({'server': 'https://issues.apache.org/jira'}),
#                 "tika")

qwe = "Merge branch 'master' of https://github.com/leopangchan/Cal-Poly-Courses"
# print (re.findall("(Merge branch 'master')", qwe))
# print (re.findall("(Merge branch 'master')", "    Tt 2017 11 001: Hearing List page"))

calpolyC = "/Users/yiupangchan/Documents/github/Cal-Poly-Courses"
shaC = "75811b9cbc5ceaae66f6b9d2b9e2fb373ec556c0"
shaC2 = "c6a12e6082dda6a9af903a1c7934e3bb39cfe143"
w = GitOperations.executeGitShellCommand(
    calpolyC, ["git when-merged -l {}".format(shaC2)])

dd = "/Users/yiupangchan/Documents/github/dd-TranscriptionTool-3.0"
shadd = "32eadf9b3a2dc07c549e154e44b2e1ac58b8ae0b"
#w = GitOperations.executeGitShellCommand(dd, ["git when-merged -l {}".format(shadd)])
'''
print (w)
from_master = len(re.findall("(master                      Commit is directly on this branch.)", w)) > 0 or len(re.findall("(Merge branch 'master')", w)) > 0
print (len(re.findall("(master                      Commit is directly on this branch.)", w)))
print (len(re.findall("(Merge branch 'master')", w)))
print (from_master)
'''
'''
    PERIL-27
'''
'''
コード例 #17
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def __checkIfTheLatestCommitCommittedThroughMaster(self):
     oneLineCommit = GitOperations.executeGitShellCommand(
         self.localRepo, ["git log --oneline -n 1"])
     output = re.search("(Merge) (branch|pull)", oneLineCommit)
     return output == None
コード例 #18
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def __hasKeywordInGitLogByRegex(self, commitSha, regex):
     consoleOut = GitOperations.executeGitShellCommand(
         self.localRepo, ["git show", commitSha])
     pattern = re.compile(regex)
     return pattern.match(consoleOut) != None
コード例 #19
0
ファイル: GitApache.py プロジェクト: dfalessi/CCP-changes
 def __isInMasterBranch(self, commitSha):
     out = GitOperations.executeGitShellCommand(
         self.localRepo, ["git branch --all --contains", commitSha])
     return len(re.findall('(master)', out)) > 0