Skip to content

Check stderr for output, that's where git fetch writes to by default#603

Merged
stefanhengl merged 2 commits into
sourcegraph:mainfrom
xvandish:indexserver-fetch-fix-for-upstream
Jun 28, 2023
Merged

Check stderr for output, that's where git fetch writes to by default#603
stefanhengl merged 2 commits into
sourcegraph:mainfrom
xvandish:indexserver-fetch-fix-for-upstream

Conversation

@xvandish

Copy link
Copy Markdown
Contributor

This is another little bugfix I've used for a while and forgot to commit up -

I added some logic in the periodicFetch function so that repos were only re-indexed if they had a fetch update, or it'd been n hours since a brute-reindex. Then I started noticing that repos that definitely had an update weren't getting re-indexed, traced the problem down and found this.

It's not a particularly elegant solution, I'm happy to modify it to be nicer. I kept outBuf around in case git ever decides to print to it & the cmd errors, in that case it'd probably be useful for debugging.

@stefanhengl stefanhengl self-requested a review June 21, 2023 07:14

@stefanhengl stefanhengl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

Comment thread cmd/zoekt-indexserver/main.go Outdated
return len(outBuf.Bytes()) != 0
return len(errBuf.Bytes()) != 0
}
return false

@stefanhengl stefanhengl Jun 21, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code (not your fix) is a bit janky. Would you mind cleaning it up a bit while you are at it? EG we could remove the else block and return early if cmd.Run() returns with an error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't mind at all! I'll give it a shot later today.

@xvandish xvandish Jun 27, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, went a little further than just changing the else block, let me know what you think.

Here's a screenshot from some print debugs to make sure it works as expected.

Screenshot 2023-06-27 at 10 42 22 AM

One thing to note for the future, as far as I can tell fetch prints actual errors to stderr as well sometimes, if we really want to be fancy we can probably switch to the --porcelain (introduced here) mode to ensure that what's printed is actually an update...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to note for the future, as far as I can tell fetch prints actual errors to stderr as well sometimes, if we really want to be fancy we can probably switch to the --porcelain (introduced here) mode to ensure that what's printed is actually an update...

That looks nice indeed!

@stefanhengl stefanhengl merged commit b9e6d94 into sourcegraph:main Jun 28, 2023
@xvandish

Copy link
Copy Markdown
Contributor Author

Thanks for fixing this!

Thanks for taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants