dirk-thomas / vcstool

Vcstool is a command line tool designed to make working with multiple repositories easier
Apache License 2.0
410 stars 86 forks source link

import doesn't pull, pull fails when version is a hash #165

Open tylerjw opened 4 years ago

tylerjw commented 4 years ago

industrial_ci is using vcstool to import from .repos or .rosinstall files into a workspace. Because we are also re-using docker images from previous runs we have the issue where the code in the workspace is out of date. The easy solution to that is to have vcs tool call pull after import. This presents a problem if the version was specified with a hash. If this was done we get a failure like this:

=== /root/upstream_ws/src/ur/universal_robots_ros_driver (git) ===
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
- git:
    local-name: ur/universal_robots_ros_driver
    uri: https://github.com/UniversalRobots/Universal_Robots_ROS_Driver
    version: 72453e14bfc262ade27c31d2086efc37a26543c6

I know that it is just running pull recursively. I'd like some way to skip pulling if the version was set explicitly like this. A way to do this with a custom git command would work too.

Another option would be to have import run the fast forward somehow, maybe a fetch and reset to the remote version?

tylerjw commented 4 years ago

The diff at the PR I linked solves my problem but I think ideally the import command should have an option for calling checkout after setting the remote and cloning (or however it works).

mathias-luedtke commented 4 years ago

If you want the latest code, why do you specify a commit?

tylerjw commented 4 years ago

I want the latest code in other repos that have branches for thier version. The UR repo is my special case where they changed something that broke our local environment and I haven't had time to go fix it so I did this temporarily. I then discovered that calling vcs pull to get the latest code (in my workspace) in the other repos caused a non-zero return value because of this one.

dirk-thomas commented 4 years ago

Because we are also re-using docker images from previous runs we have the issue where the code in the workspace is out of date.

The current import logic is unfortunately not suited for this use case. I would certainly be nice if it would support it.

I'd like some way to skip pulling if the version was set explicitly like this.

When invoking vcs pull there is no explicit version since there is no input yaml file. The command solely operates on the filesystem. Atm it simply invokes git pull and returns its output and return code. The logic could be changed to not invoke git at all if the working copy is not tracking any branch.

Another option would be to have import run the fast forward somehow, maybe a fetch and reset to the remote version?

Resetting to the remote version is something I think import shouldn't do without an explicit option (maybe --force). Attempting a merge --ff-only sounds reasonable.

dirk-thomas commented 4 years ago

@tylerjw Please give #166 a try which only shows the message about You are not currently on a branch... as a warning (in yellow) rather than as an error (in red) and therefore doesn't result in a non-zero return code (which is what git returns for trying to pull a detached HEAD).