make branch handling smarter

Look at the branches that actually exist in the repository rather than
assuming all of the branch names. This lets us handle the charms team
repos, which have numerical branches.

Change-Id: I9ebd90eb716fb26db7aa09edff0de663872c5964
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-09-11 16:33:31 -04:00
parent d224ca07a5
commit 372dc41782
6 changed files with 103 additions and 22 deletions

View File

@ -77,8 +77,6 @@ $bindir/update_doc_job.sh "$out_dir" "$team" $task_id
$bindir/add_py35_job.sh "$out_dir" "$team" $task_id
$bindir/add_py36_job.sh "$out_dir" "$team" $task_id
$bindir/add_lib_job.sh "$out_dir" "$team" $task_id
$bindir/process_team.sh "$out_dir" "$team" stable/ocata $task_id
$bindir/process_team.sh "$out_dir" "$team" stable/pike $task_id
$bindir/process_team.sh "$out_dir" "$team" stable/queens $task_id
$bindir/process_team.sh "$out_dir" "$team" stable/rocky $task_id
$bindir/process_team_stable.sh "$out_dir" "$team" $task_id
$bindir/update_project_config.sh "$workdir" "$team" $task_id $repos

View File

@ -37,3 +37,12 @@ function log_output {
date
echo $0 $@
}
function list_stable_branches {
local repodir="$1"
(cd $repodir &&
git branch --list -a |
grep origin/stable |
sed -e 's|remotes/origin/||g')
}

View File

@ -49,13 +49,13 @@ for repo in $(ls -d $workdir/*/*); do
# Create the branch tracking file, since some other tools assume
# it exists. Having it empty is fine.
touch $workdir/$(basename $branch)
touch $workdir/branch-$(basename $branch)
$bindir/do_repo.sh "$repo" "$branch" "$task"
RC=$?
if [ $RC -eq 0 ]; then
tracking="$(basename $(dirname $repo))/$(basename $repo)"
echo "$tracking" >> $workdir/$(basename $branch)
echo "$tracking" >> $workdir/branch-$(basename $branch)
elif [ $RC -ne 2 ]; then
echo "FAIL"
exit $RC

View File

@ -0,0 +1,69 @@
#!/bin/bash -x
bindir=$(dirname $0)
source $bindir/functions
echo
echo "=== process team $2 ==="
echo
echo $0 $*
echo
function usage {
echo "process_team_stable.sh WORKDIR TEAM TASK"
}
workdir=$1
team="$2"
task="$3"
if [ -z "$workdir" ]; then
usage
exit 1
fi
if [ -z "$team" ]; then
usage
exit 1
fi
if [ -z "$task" ]; then
usage
exit 1
fi
enable_tox
function do_repo_branch {
local repo="$1"
local branch="$2"
echo
echo "=== $repo @ $branch ==="
echo
# Create the branch tracking file, since some other tools assume
# it exists. Having it empty is fine.
tracking_file="$workdir/branch-$(basename $branch)"
touch "$tracking_file"
$bindir/do_repo.sh "$repo" "$branch" "$task"
RC=$?
if [ $RC -eq 0 ]; then
tracking="$(basename $(dirname $repo))/$(basename $repo)"
echo "$tracking" >> "$tracking_file"
elif [ $RC -ne 2 ]; then
echo "FAIL"
exit $RC
fi
}
for repo in $(ls -d $workdir/*/*); do
branches=$(list_stable_branches $repo)
for branch in $branches; do
do_repo_branch "$repo" "$branch"
done
done
exit 0

View File

@ -26,18 +26,18 @@ log_output "$out_dir" propose
enable_tox
BRANCHES="master ocata pike queens rocky"
function list_changes {
for branch in $BRANCHES
for branchfile in branch-*
do
for repo in $(cat $branch)
branch=$(echo $branchfile | sed -e 's|.*-||g')
if [ "$branch" = "master" ]
then
origin=origin/master
else
origin=origin/stable/$branch
fi
for repo in $(cat $branchfile)
do
if [ $branch = master ]; then
origin=origin/master
else
origin=origin/stable/$branch
fi
(cd $repo &&
git checkout python3-first-$branch 2>/dev/null &&
git log --oneline --pretty=format:"%h %s $repo $branch%n" $origin..)
@ -59,14 +59,18 @@ echo
echo "Press enter to continue"
read ignoreme
for branch in $BRANCHES
branches="master $(list_stable_branches $repo)"
for branchfile in branch-*
do
if [ $branch = master ]; then
branch=$(echo $branchfile | sed -e 's|.*-||g')
if [ "$branch" = "master" ]
then
target=master
else
target=stable/$branch
fi
for repo in $(cat $branch)
for repo in $(cat $branchfile)
do
echo
echo $repo $branch

View File

@ -26,12 +26,11 @@ log_output "$out_dir" show
enable_tox
BRANCHES="master ocata pike queens rocky"
function show_changes {
for branch in $BRANCHES
for branchfile in branch-*
do
for repo in $(cat $branch)
branch=$(echo $branchfile | sed -e 's|.*-||g')
for repo in $(cat $branchfile)
do
echo
if [ $branch = master ]; then
@ -41,7 +40,9 @@ function show_changes {
fi
(cd "$repo" &&
git checkout python3-first-$branch 2>/dev/null &&
echo "========================================" &&
echo "CHANGES IN $repo $branch" &&
echo "========================================" &&
echo &&
git log --patch $origin..)
done