Giter VIP home page Giter VIP logo

Comments (2)

ziggystar avatar ziggystar commented on May 26, 2024

But I also tried the following code, which I found on the internet. Maybe that's a better method to get the commit infos. But it cannot easily be swapped, as the behavior is different in non-standard cases.

  def getCommitLogFast(git: Git, from: String, to: String): List[CommitInfo] = {
    val since = git.getRepository.resolve(from)
    val until = git.getRepository.resolve(to)
    git.log.addRange(since, until).call.asScala.map(new CommitInfo(_)).toList.reverse
  }

I wrote the following tests, note the comments next to the cases. The 00000 I encountered when pushing a lot of commits to my stale test GB installation. I don't know what that means and whether this must be supported.

  test("getCommitLogFast returns correct commits") {
    withTestRepository { git =>
      val c1 = createFile(git, Constants.HEAD, "README.md", "body1", message = "commit1")
      val c2 = createFile(git, Constants.HEAD, "README.md", "body2", message = "commit2")
      val c3 = createFile(git, Constants.HEAD, "README.md", "body3", message = "commit3")

      for (
        (from, to, msg) <- List(
          (c1.name, c3.name, "1-3"),  // OK
          (c2.name, c3.name, "2-3"),  // OK
          (c1.name, c2.name, "1-2"),  // OK
          (c3.name, c1.name, "3-1"),  // FAIL: fast: NIL, old: 1 commit
          ("000000000000000", c3.name, "000000-3") // FAIL: fast: NPE b/c of unknown commit
        )
      ) {
        val fast = JGitUtil.getCommitLogFast(git, from, to)
        val old = JGitUtil.getCommitLog(git, from, to)
        assert(fast == old, msg)
      }
    }
  }

Overall, I don't know if it's worth changing to this method.

from gitbucket.

ziggystar avatar ziggystar commented on May 26, 2024

I have a PR with a new implementation of getCommits that works for rebases (it calculates a merge-base/common ancestor).

Problem is, sometimes (e.g. new repo), I get commit names 000000000...0, and those can't be resolved. Where are those coming from? What's the correct behavior there? Are those names generated by GB?

from gitbucket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.