Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the use case of not using mergebase for --since #514

Closed
SamChou19815 opened this issue Jan 6, 2022 · 6 comments
Closed

Support the use case of not using mergebase for --since #514

SamChou19815 opened this issue Jan 6, 2022 · 6 comments
Labels
area: ergonomics Issues and features impacting the developer experience of using turbo

Comments

@SamChou19815
Copy link

SamChou19815 commented Jan 6, 2022

Describe the feature you'd like to request

I am trying to integrate turborepo in my GitHub actions workflow.

I want to avoid checking out the entire history, so I tried to only check out two commits: the base commit and the merge commit of the pull request. Then I want to use --since=[base-commit] to only rebuild what has been affected by the request.

However, this will result in a fatal error due to these lines:

if fromCommit != "" {
// Grab the diff from the merge-base to HEAD using ... syntax. This ensures we have just
// the changes that have occurred on the current branch.
command = []string{"diff", "--name-only", fromCommit + "...HEAD"}
out, err = exec.Command("git", append(command, relSuffix...)...).CombinedOutput()
if err != nil {
log.Fatalf("unable to check diff vs. %s: %s", fromCommit, err)
}
committedChanges := strings.Split(string(out), "\n")
files = append(files, committedChanges...)
}

Example of failed run: https://github.com/SamChou19815/infra/pull/25

When using three dots, git will try to find the mergebase between the two commits, which usually does not exist when you only checkout two isolated commits. I would like to support the use case so I don't have to checkout the entire history just for an incremental build from turborepo.

Describe the solution you'd like

An option that runs git diff --name-only fromCommit..HEAD under the hood would be great.

Describe alternatives you've considered

Use build cache instead?

@attila
Copy link

attila commented Feb 23, 2022

I'm affected by this too. Trying to migrate from a lerna monorepo where PR builds run based on the diff between HEAD and the base ref – which are fetched individually prior to the build step.

Screenshot 2022-02-23 at 10 48 11 am

If above code used something like git diff --name-only <fromCommit>..HEAD then it would work just fine. Not sure of other implications, of course.

@attila
Copy link

attila commented Feb 23, 2022

A potential workaround is to fetch enough history so that diffing via a merge-base becomes possible. It looks like https://github.com/rmacklin/fetch-through-merge-base is attempting to achieve exactly that.

It still is considered a kludge in my opinion, and support for an option to use ..-style diffs would be desirable.

@jaredpalmer
Copy link
Contributor

Can you suggest how you'd like to specify ... vs. .. via command line flags?

@SamChou19815
Copy link
Author

Maybe there can be a flag like --no-mergebase or a separate flag like --diff=[commit] that signals we only care about the diff between two commits.

@graup
Copy link

graup commented Mar 14, 2022

+1 on the issue. I had opened a discussion but seems is the same. #805

If we cannot fix it, at the very least we could improve the error message and documentation.

Could someone explain what the advantage of "..." is over ".." in this case?

sokra added a commit that referenced this issue Oct 25, 2022
omit module and exports from ESM
@mehulkar mehulkar added story area: ergonomics Issues and features impacting the developer experience of using turbo labels Oct 20, 2023
@anthonyshew
Copy link
Contributor

--since is deprecated so will close this as out of date!

@anthonyshew anthonyshew closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ergonomics Issues and features impacting the developer experience of using turbo
Projects
None yet
Development

No branches or pull requests

6 participants