Code Monkey home page Code Monkey logo

Comments (5)

foosinn avatar foosinn commented on July 22, 2024

Drone does not always provide a last commit. Was the branch created with the push?

When drone provides no last build, drone-tree-config asumes just the last one. If you open a pull request the tests should be fine.

from drone-tree-config.

gevalter avatar gevalter commented on July 22, 2024

Yes, the branch was created with the push after the last commit. And you are right, pull request & Merge builds do solve the problem but we do some test on the branch level before pushing to master.

Maybe if I change this part to take the master branch as the before variable it would work? Or you think it will break something else?

// use diff to get changed files before := req.Build.Before if before == "0000000000000000000000000000000000000000" || before == "" { before = fmt.Sprintf("%s~1", req.Build.After) } var err error changedFiles, err = req.Client.ChangedFilesInDiff(ctx, before, req.Build.After)

from drone-tree-config.

foosinn avatar foosinn commented on July 22, 2024

i do not think its save to assume that the default branch is master.

also as far as i remember there where at least occasions where this happened

  • new branches
  • build restarts

currently i do not have the time for a full test setup. can you investigate further?

from drone-tree-config.

gevalter avatar gevalter commented on July 22, 2024

Hey, I found the bug and fixed it for our use case, i also edit the tests module, added the values needed for my solution to work, I opened a PR for this changes.

The problem was for builds triggered from push event, there was a git-diff between the last commit and the one before, that is wrong - when you push to remote branch in a multi branch environment - sometimes you have more than 1 commit.

scm.go:
} else { // use diff to get changed files before := req.Build.Before if before == "0000000000000000000000000000000000000000" || before == "" { before = fmt.Sprintf("%s~1", req.Build.After) }

There are 2 cases -

  1. New branch - condition is true, the "before" variable is populated with the last commit with a suffix of "~1", (which i don't understand why you inserted the suffix), and the "after" variable is also the last commit.
  2. Existing branch - condition is false, the "before" variable is populated with the commit before the push event and the "after" variable is also the last commit.

from drone-tree-config.

foosinn avatar foosinn commented on July 22, 2024

PR has been merged.

from drone-tree-config.

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.