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

fix($last-updated): use file author time instead of submodule commit time (1.x) #1640

Merged
merged 1 commit into from
Sep 10, 2019

Conversation

DvdGiessen
Copy link
Contributor

Summary
When using a Git submodule, the "last updated" time for all files within that submodule is incorrect.

This happens because the git log command, when operating from a working directory that is part of the parent repository, only operates on that parent repository. As a result, any query for the log for a specific file that is located in a submodule will return the log for the submodule entry itself.

So, for example, if we have a submodule /foo and a file /foo/bar.md, then even if bar.md was last updated many years ago, if we commited a update of the submodule five minutes ago that will cause Vuepress to show that bar.md was last updated 5 minutes ago, while in fact it hasn't.

This pull request resolves this bug by first changing the current working directory to the directory containing the file, so that if the file is part of a submodule, git log accesses the log of the submodule and retrieves the correct last updated time from that files history instead of only considering the submodule history of the parent repository. This of course also works the same for repositories without submodules so does not require any additional checks or workarounds.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

You have tested in the following browsers: (Providing a detailed version will be better.)

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE
  • Checked generated code in text editor

Other information:
I've also opened a pull request with the exact same changes for 0.x, see #1639.

@flozero
Copy link
Collaborator

flozero commented Sep 5, 2019

hello @DvdGiessen thank's for the work and time ! Can you maybe provide a test for it ?

@flozero flozero added status: community assigned Community assigned topic: plugins Relates to VuePress plugins type: enhancement Request to enhance an existing feature version: 1.x Relates to version 1 of VuePress labels Sep 5, 2019
@DvdGiessen
Copy link
Contributor Author

I'm afraid I won't be able to provide a test for this change any time soon; there are no existing tests for this functionality for me to quickly update and unfortunately I currently don't have much time to spend on writing a complete test for this plugin. Sorry!

I agree that is would be desirable to have tests for this functionality, so anyone else wants to take a look I welcome them very much to pick my small contribution and improve upon it with some proper tests. :)

Copy link
Collaborator

@kefranabg kefranabg left a comment

Choose a reason for hiding this comment

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

Thanks for your work @DvdGiessen 👍

@kefranabg kefranabg merged commit f964391 into vuejs:master Sep 10, 2019
@vue-bot
Copy link

vue-bot commented Sep 10, 2019

Hey @DvdGiessen, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: community assigned Community assigned topic: plugins Relates to VuePress plugins type: enhancement Request to enhance an existing feature version: 1.x Relates to version 1 of VuePress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants