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

Better documentation for edge cases of commit command #49

Closed
yuhr opened this issue Dec 12, 2018 · 5 comments
Closed

Better documentation for edge cases of commit command #49

yuhr opened this issue Dec 12, 2018 · 5 comments
Labels
chore Very simple enhancements

Comments

@yuhr
Copy link
Contributor

yuhr commented Dec 12, 2018

isomorphic-git/isomorphic-git#643 (comment)

I'm kind of confused by lots of thoughts 🤔

For instance, what if:

commit({ ...,
  author: {
    name: 'someone',
    email: '...',
    date: new Date('August 19, 2012 23:15:30')
  },
  committer: {
    name: 'me'
    email: '...'
  }
})

In this case, I guess the user has intended to set author's date to several years ago but apparently still wants to commit just now as himself, because the docs page says nothing about such a case though seeing author.date it says just "Default is the current date". But current implementation won't do that. This way the user is likely to get a misdated commit object accidentally. I don't know what is your design decision actually @wmhilton @mojavelinux, anyway I just followed to this behaviour in #643 with 5bc1d66.

Here's another instance:

commit({ ...,
  author: {
    name: 'someone',
    email: '...'
  }
})

We expect the auther to be also the committer in this case, but what if the user didn't read the docs well and was to commit as himself using default values in .git/config, not author? This case is pretty hard to prevent from having unexpected commits. Although I don't think such a tiny edge case is worth supporting, acually.

Also what if:

commit({ ...,
  author: {
    name: 'someone',
    email: '...'
  },
  committer: {
    name: 'me'
    email: '...',
    date: new Date('August 19, 2012 23:15:30')
  }
})

I can't imagine the case author's date is later than committer's, however I'm not sure whether we should default it to committer's or now. For API consistency, we may want to choose the latter.

So... even though we don't make such breaking changes, we may want to write some explicit notes with highlighted style in the docs about them, and of course it's also possible to throw some errors for such ambiguous parameter patterns.

@yuhr yuhr changed the title Consider how to treat multiple cases of commit command Consider how to treat edge cases of commit command Dec 12, 2018
@yuhr
Copy link
Contributor Author

yuhr commented Dec 12, 2018

Oh, tricky users might do this kind of thing 🤣

commit({ ...,
  author: {
    name: 'someone',
    email: '...'
  },
  committer: {}
})

Well. The silver bullet could be to make parameters required, if it's not breaking things too much lol.

@billiegoose
Copy link
Member

Yeah... and the scenario I was trying to mentally calculate was what happens if:

commit({ ...,
  author: {
    name: 'someone',
    email: '...',
    date: new Date('Thu Dec 13 2018 22:47:25 GMT-0500')
  },
  committer: {
    name: 'me'
    email: '...',
    timestamp: 1544759187
  }
})

They would end up with the committer using the provided timestamp... but the time ZONE from author instead of the current time zone.

@billiegoose
Copy link
Member

I'm not sure what to do about these situations. Maybe just improve the docs? Right now all it says for committer is "If not specified, the author details are used." If we expanded it to list each field and indicated the default value, then it would be more clear.

@mojavelinux
Copy link
Contributor

Maybe just improve the docs?

That would be my philosophy here. There's a point when you have to specify what's ambiguous and trust the user of the API to pass in sensible values.

@billiegoose billiegoose transferred this issue from isomorphic-git/isomorphic-git Dec 15, 2018
@billiegoose billiegoose changed the title Consider how to treat edge cases of commit command Better documentation for edge cases of commit command Dec 15, 2018
@billiegoose billiegoose added the chore Very simple enhancements label Dec 15, 2018
@yuhr
Copy link
Contributor Author

yuhr commented Dec 16, 2018

Let's go with that! 😄

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

No branches or pull requests

3 participants