-
Notifications
You must be signed in to change notification settings - Fork 36
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
Make tsrc sync
optionally automatically git stash & pop to update the default branch even if current is dirty
#286
Comments
You're welcome to try ;) My instincts tell me it's going to be difficult to implement and use because just naming the behavior is hard. You have to find something shorter than Actually, I think we scould address this kind of feature request without having to change the behavior of I've created an issue about that here: #287. Feel free to add your feedback there. |
So I went ahead and tried it. I started with a workspace like this:
Then I wrote a # in workspace/sync.sh
if [[ "${TSRC_PROJECT_STATUS_DIRTY}" = "true" ]]; then
echo project is dirty
exit 1
fi
git switch $TSRC_PROJECT_MANIFEST_BRANCH
git pull And finally, I ran:
Easy Peasy :) |
By the way you can write the |
@gdubicki should we close this ? |
Thank you for providing a workaround with the script, @dmerejkowsky , but frankly I would still really love to have this feature included in tsrc... One reason is that I am lazy and forgetful ;P and I don't want to have this extra step to make my tsrc fully working on a new machine. The other is that I want this workflow to be used throughout my global company and rolling out a solution that will require an extra script and non-standard command is much more difficult than telling about a new cli parameter. But in the mean time I realized that what I actually do and what I would like to automate, is a bit different behavior. After running
This way I restore it to the dirty state it was in, but the default branch is up to date. I think that this behavior should be safe to be enabled as the new default. Or at least be configurable in the workspace config, so that we could roll out the new config along with the manifest update. What do you think, @dmerejkowsky ? |
tsrc sync
change repos to default branch, if not dirty, and then updatetsrc sync
optionally automatically git stash & pop to update the default branch even if current is dirty
Well, I tried that already in a previous project a long time ago. It's doable of course, but things start to get really tricky if anything goes wrong. For instance, what do you do if step 3 fails? If step 6 fails? I really don't want tsrc to be 'suprising' in any way - better do less that do unexpected or confusing things.
Maybe we need a command for that, then In all seriousness, I'm also wondering if the steps 1 to 6 should be a feature of git itself ?
I know that, but various users have various needs and at one point we have to say no or the tool becomes to complex to use and to hard to maintain. |
Maybe something with |
You can change your git config in the repo or globally to achieve same goal
|
Well, what you're proposing does not do step 3 and 5 (where we temporarily switch branches and back). But it works well with |
It also works well with |
I'm confused. |
This is exactly the case I've already faced. We have hundreds of repos and usually I forget to switch branches after the specific task in the specific repo is finished. Then I want to sync everything with I understand you don't want to make it a default behavior. What do you think to add the possibility to configure e.g. within the manifest file to enable such an option? |
I prefer talking about the It's a really flexible method and you can put it under version control for your organization if you like :) I don't think a manifest option in the file would work because I'm pretty sure not everyone will use the same workflow. If enough people start complaining, maybe we'll add more options to Or maybe we need aliases, ala git ... |
I did try it and it works but it's not doing the same things as
How about putting it into workspace configuration then? If I get it right this is a per-user config, not shared.
So would you accept a PR with adding such optional, non-default mode for sync + allowing to make it default for a given workspace with a setting with it? |
Hum. I think you're right. Did not think about that.
Maybe... This sounds a bit complicated, though. Perhaps we could have a separate command at first ? In a previous version of this tool we ended up with So I fear that naming new option (or command) would be pretty hard, but feel free to try ;) |
Of course it would need more polish, but how about we first do what I implemented in #370? The default behavior doesn't change, it requires only a one-time manifest update and it works for the simple and safe case when the repo is clean. |
See also #375. |
I understand and am all for the current default behavior of
tsrc sync
, which when it encounters a repo that is not on the branch configured in the manifest, just prints this info out and does not do anything with it.However, in my use case, I would always prefer
tsrc
to check if that repo is not dirty and if not, then switch to the branch defined in the manifest and dogit pull
.Would a PR adding such optional and disabled by default, behavior be accepted?
The text was updated successfully, but these errors were encountered: