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

Prevent extra commit to metadata file on first edit #67

Closed
durden opened this issue May 5, 2016 · 3 comments
Closed

Prevent extra commit to metadata file on first edit #67

durden opened this issue May 5, 2016 · 3 comments
Labels

Comments

@durden
Copy link
Contributor

durden commented May 5, 2016

Consider the following scenario:

  • User creates new guide
    • This triggers 2 commits, 1 for the guide itself and 1 for the metadata.
  • User immediately comes back and edits guide text
    • This should trigger only 1 commit, but it triggers 2. 1 for the guide text itself and 1 to unset the first_commit attribute in the metadata.

We should never modify the first_commit attribute once it has been set!

@durden
Copy link
Contributor Author

durden commented May 5, 2016

Just a bit of background:

We have an attribute in the meta data called first_commit. This attribute was added in a32a77d solely for the purpose of giving us a unique id to use with our disqus comments. Usually you would use a database provided id here but since git is essentially our database this is the best option.

first_commit is also used to trigger when we switched to version .2, which changed the URLs for all guides. We needed to know if a guide was created before this change or not so we could properly save our social shares using the po.st service. This service doesn't support 301 redirects so we needed to set the url parameter directly so the shares would move with the guides.

@durden
Copy link
Contributor Author

durden commented May 5, 2016

Unfortunately this bug has existed for a while, but it's not causing any severe issues. It does cause these minor issues though:

  • Creates 1 extra commit to the metadata as described in the OP
  • Makes the first_commit attribute completely useless
  • Forces us to use only the title attribute as the disqus id
  • Incorrectly sets the url for po.st sharing as the old url /review/ scheme

None of those problems are deal-breakers. However, we should fix this so we can truly support comments and po.st sharing for guides with duplicate titles (not duplicate stacks though).

@durden
Copy link
Contributor Author

durden commented May 5, 2016

We have to be careful how we fix this to avoid losing all our previous po.st share data or losing the disqus comments. The trick is to make sure we never update any guide's first_commit attribute if that guide was created before this fix. Essentially, this is prolonging the fix we tried to put in place from version .2. So, we'll treat all null first_commit attributes as happening before we had the ability to track this.

That means all the old share data and disqus data will stay as is. However, guides created after this fix will always have a valid first_commit attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant