-
Notifications
You must be signed in to change notification settings - Fork 49
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
Allow changing the git branch #137
Conversation
b0bcd7d
to
3b414e8
Compare
@naggie This is finally ready. I was stumped for a long time, because the tests were relying on git features that were too new. Specifcally this: git/git@32ba12d So, I was confused because I could not reproduce the error locally on Manjaro, which gives me the newer git version 2.32 I don't believe we really need to set a different default in the tests, however. It should be sufficient to check that nothing breaks. |
@naggie bump ❤️ |
Sorry -- caught up in too much stuff at the moment. I'm worried this could break some existing repositories without an upstream tracking master/main branch. Is that an issue, or are we somehow protected? If not perhaps dstask should guide to a solution? |
I will look into this scenario. 👍 |
Thank you |
You are right, it is a potential problem. I created a test environment for this branch as a linux container. With no default upstream,
Git itself nudges the user in the right direction, but it's not the best. I was hoping to implement this feature with no additional config, but now I am leaning towards a new configuration variable: DSTASK_BRANCH We have at least 3 options
|
If you are interested in running my test container, it's public here. This branch's version of
I prefer podman, but docker should work. The build script (again with buildah, not docker) script#!/bin/bash
set -ex
container_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin"
golang_url="https://golang.org/dl/go1.14.15.linux-amd64.tar.gz"
feature_branch="https://github.com/dontlaugh/dstask/archive/refs/heads/116_default_branch.zip"
pkgs="git wget unzip make"
id=$(buildah from --name dstask-test-116 --pull "docker://ubuntu:18.04")
buildah run $id -- apt update -y
buildah run $id -- apt install -y $pkgs
buildah run $id -- wget $golang_url
buildah run $id -- tar -C /usr/local -xzf "go1.14.15.linux-amd64.tar.gz"
buildah run $id -- useradd -m testuser -s /bin/bash
buildah config \
--env PATH=$container_path \
--user testuser \
--cmd /bin/bash \
--workingdir /home/testuser \
$id
buildah run --user "testuser:testuser" $id -- wget $feature_branch
buildah run --user "testuser:testuser" $id -- unzip 116_default_branch.zip
buildah run --user "testuser:testuser" $id -- \
bash -c "cd dstask-116_default_branch && make"
buildah run --user "root:root" $id -- \
bash -c "cd dstask-116_default_branch && make install"
buildah commit $id quay.io/colemanx/dstask-test-116:latest
|
We should be able to rely on pushing and pulling from the default branch without explicitly setting "master", or anything else. dstask will simply push and pull from the remote named "origin" using whatever default tracking branch is set. In git 2.32, it's possible to specify the default initial branch for git repositories. This is globally configurable with **init.defaultBranch**. See `man git-init` for details. Refs naggie#116
27f3b2b
to
0d67353
Compare
A globally-set --ff-only means a git pull will refuse to fall back to merge commit if a fast forward cannot be set. This causes sync errors more frequently. Let's prefer setting --ff explicitly, making the choice on behalf of the user to prefer merge commits to failures. The only downside is the non-linear commit history, but this seems minor, given our use case. See `git pull --help`
@naggie I believe this is ready for re-review. Let me know if you want me to squash this down. |
So which option out of the 3 are we pursuing now? If there is an origin, then why would we default to master rather than looking at which branch is used to sync with origin? |
I have implemented option 1. I was hoping to avoid any config. And I do think that number 2 is possible. But using an explicit DSTASK_BRANCH configuration variable leads us to a simpler implementation (probably). The current behavior is hardcoded to "master". |
I know it's annoying when people chime in after much of the work has already been done, so apologies for being late. It sounds like the issue brought up by @naggie is that of users wishing to sync, but don't have a remote tracking branch set up.
I think adding config options and env vars should not be done lightly. Especially when they must be set if you want the tool to work. It complicates things, especially for new users. I rather focus more on initial setup rather than an env var which must be permanently set. As a reminder, one of the values we set out in #90 is:
|
No apology necessary! |
@Dieterbe I think that's a really good pragmatic solution that effectively delegates this configuration to git such that we don't need to add unnecessary config to git. Sorry @dontlaugh I think we should abandon this implementation in favour of requiring a remote tracking branch to be set up such that git push/pull work implicitly. Thanks both |
We should be able to rely on pushing and pulling from the default
branch without explicitly setting "master", or anything else. dstask
will simply push and pull from the remote named "origin" using whatever
default tracking branch is set.
In git 2.32, it's possible to specify the default initial branch for git
repositories. This is globally configurable with init.defaultBranch.
See
man git-init
for details.Closes #116