cro3 icon indicating copy to clipboard operation
cro3 copied to clipboard

`repo upload --wip --no-verify .` should be an easy single command

Open hikalium opened this issue 1 year ago • 6 comments

problem statement

pre-submit check is very useful. However, repo upload command with --wip flag is used for uploading the WIP CL to save the current state sometimes. running pre-check on such WIP change is just adding more psychological barrier to save that in the cloud, which increases the possibility to loss the change on some random causes (e.g. broken workstation, git operation mistake, etc...)

proposed solution

introduce lium cl save command to save the work-in-progress change easily.

if the local change has multiple commits, it should be squashed just for uploading in some way (TBD), to avoid creating extra CLs accidentally.

maybe introduce lium cl upload for set the CL active for review.

things to consider

  • How to squash the commits automatically? (git v.s. Gerrit semantics)
  • consider running presubmit tests for printing-out warnings...? (but it may slows down the cycle)
  • automatic branch upstream fix (it's annoying...)

hikalium avatar Nov 21 '23 12:11 hikalium

My /work/scripts/fix_branch_upstream_to.sh to fix the branch upstream is something like this:

#!/bin/bash -xe

sudo apt install python3-xmltodict
pip install yq

PROJ=$(repo status . | cut -d ' ' -f 2 | sed -E 's#/$##g')
echo PROJ=${PROJ}
if [ "$PROJ" = "src/platform/crosvm" ]; then
        echo "This is crosvm";
        git branch --set-upstream-to=cros/main
        exit;
fi
DEST_BRANCH=`repo manifest | xq | jq -r ".manifest.project[] | select(.\"@path\"==\"${PROJ}\").\"@dest-branch\""`
echo Destination branch: ${DEST_BRANCH}
UPSTREAM_BRANCH=cros/`echo ${DEST_BRANCH} | sed -E s@refs/heads/@@g`
echo Upstream branch: ${UPSTREAM_BRANCH}
git branch --set-upstream-to=${UPSTREAM_BRANCH}

hikalium avatar Nov 21 '23 12:11 hikalium

(workstation) $ repo upload --cbr --wip --yes .
WARNING: Manifest URL has changed since pre-upload was allowed.

Run hook scripts from https://chrome-internal.googlesource.com/chromeos/manifest-internal (yes/always/NO)?

sadly, this prompt keeps showing up even with --yes... sad... (we should fix that later)

hikalium avatar Nov 21 '23 12:11 hikalium

the repo command will be:

repo upload --cbr --wip -y --no-verify .

hikalium avatar Nov 21 '23 12:11 hikalium

Also, crosvm requires extra care upon the branch upstream fix:

# https://crosvm.dev/book/building_crosvm/linux.html
# https://crosvm.dev/book/contributing/contributing.html

# Add remote upstream if it is not there yet
git remote -v | grep 'https://chromium.googlesource.com/crosvm/crosvm' | cut -f 1 | grep upstream >/dev/null || git remote add upstream https://chromium.googlesource.com/crosvm/crosvm
# fetch upstream first
git fetch upstream main
# set upstream of the branch to upstream/main
git branch --set-upstream-to=upstream/main

hikalium avatar Nov 21 '23 12:11 hikalium

ah, and it looks like they cannot be rebased manually since cros/main and upstream/main have different commits each... sigh...

hikalium avatar Nov 21 '23 13:11 hikalium

Also, to upload a crosvm CL, we have to run:

./tools/cl upload --help

hikalium avatar Nov 21 '23 13:11 hikalium