Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146536287
D47289.id145473.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D47289.id145473.diff
View Options
diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh
--- a/tools/tools/git/git-arc.sh
+++ b/tools/tools/git/git-arc.sh
@@ -229,7 +229,7 @@
diff2status()
{
- local diff tmp phid status status_color status_name summary term_color
+ local diff phid status status_color status_name summary term_color
diff=$1
if ! expr "$diff" : 'D[1-9][0-9]*$' >/dev/null; then
@@ -237,11 +237,11 @@
fi
tmp=$(mktemp)
+ trap cleanup EXIT HUP INT QUIT TRAP USR1 TERM # 0 1 2 3 5 10 15
echo '{"names":["'"$diff"'"]}' |
arc_call_conduit -- phid.lookup > "$tmp"
phid=$(jq -r ".response[].phid" "$tmp")
if [ -z "$phid" ] || [ "$phid" = "null" ]; then
- rm -f "$tmp"
err "invalid Phabricator ID for ${diff}"
fi
@@ -255,7 +255,6 @@
summary=$(jq -r "select(.response != []) |
.response.${diff}.fullName" < "$tmp")
printf "${term_color}%-15s\033[0m %s\n" "${status_name}" "${summary}"
- rm -f "$tmp"
}
log2diff()
@@ -315,7 +314,7 @@
create_one_review()
{
- local childphid commit doprompt msg parent parentphid reviewers
+ local childphid commit doprompt parent parentphid reviewers
local subscribers
commit=$1
@@ -329,6 +328,7 @@
fi
msg=$(mktemp)
+ trap cleanup EXIT HUP INT QUIT TRAP USR1 TERM # 0 1 2 3 5 10 15
git show -s --format='%B' "$commit" > "$msg"
printf "\nTest Plan:\n" >> "$msg"
printf "\nReviewers:\n" >> "$msg"
@@ -357,7 +357,6 @@
]}' |
arc_call_conduit -- differential.revision.edit >&3
fi
- rm -f "$msg"
return 0
}
@@ -596,26 +595,27 @@
diff=$1
reviewid=$(diff2phid "$diff")
+ tmp_data_dir=$(mktemp -d)
+ trap cleanup EXIT HUP INT QUIT TRAP USR1 TERM # 0 1 2 3 5 10 15
# Get the author phid for this patch
- review_data=$(mktemp)
+ review_data="${tmp_data_dir}/review"
echo '{"constraints": {"phids": ["'"$reviewid"'"]}}' | \
arc_call_conduit -- differential.revision.search > "$review_data"
authorid=$(jq -r '.response.data[].fields.authorPHID' "$review_data")
# Get metadata about the user that submitted this patch
- user_data=$(mktemp)
+ user_data="${tmp_data_dir}/user"
echo '{"constraints": {"phids": ["'"$authorid"'"]}}' | \
arc_call_conduit -- user.search | \
jq -r '.response.data[].fields' > "$user_data"
user_addr=$(jq -r '.username' "$user_data")
user_name=$(jq -r '.realName' "$user_data")
- rm "$user_data"
# Dig the data out of querydiffs api endpoint, although it's deprecated,
# since it's one of the few places we can get email addresses. It's unclear
# if we can expect multiple difference ones of these. Some records don't
# have this data, so we remove all the 'null's. We sort the results and
# remove duplicates 'just to be sure' since we've not seen multiple
# records that match.
- diff_data=$(mktemp)
+ diff_data="${tmp_data_dir}/diff"
echo '{"revisionIDs": [ '"${diff#D}"' ]}' | \
arc_call_conduit -- differential.querydiffs |
jq -r '.response | flatten | .[]' > "$diff_data"
@@ -632,7 +632,6 @@
fi
author=$(find_author "$user_addr" "$user_name" "$author_addr" "$author_name")
- rm "$diff_data"
# If we had to guess, and the user didn't want to guess, abort
if [ "${author}" = "ABORT" ]; then
@@ -640,12 +639,11 @@
exit 1
fi
- tmp=$(mktemp)
+ tmp="${tmp_data_dir}/tmp"
jq -r '.response.data[].fields.title' "$review_data" > $tmp
echo >> $tmp
jq -r '.response.data[].fields.summary' "$review_data" >> $tmp
echo >> $tmp
- rm "$review_data"
# XXX this leaves an extra newline in some cases.
reviewers=$(diff2reviewers "$diff" | sed '/^$/d' | paste -sd ',' - | sed 's/,/, /g')
if [ -n "$reviewers" ]; then
@@ -654,7 +652,6 @@
# XXX TODO refactor with gitarc__stage maybe?
printf "Differential Revision:\thttps://reviews.freebsd.org/%s\n" "${diff}" >> "$tmp"
git commit --author "${author}" --file "$tmp"
- rm "$tmp"
}
gitarc__patch()
@@ -691,7 +688,7 @@
gitarc__stage()
{
- local author branch commit commits diff reviewers title tmp
+ local author branch commit commits diff reviewers title
branch=main
while getopts b: o; do
@@ -715,6 +712,7 @@
fi
tmp=$(mktemp)
+ trap cleanup EXIT HUP INT QUIT TRAP USR1 TERM # 0 1 2 3 5 10 15
for commit in $commits; do
git show -s --format=%B "$commit" > "$tmp"
title=$(git show -s --format=%s "$commit")
@@ -735,7 +733,6 @@
fi
git commit --edit --file "$tmp" --author "${author}"
done
- rm -f "$tmp"
}
gitarc__update()
@@ -795,6 +792,14 @@
done
}
+cleanup()
+{
+ rc=$?
+ rm -fr $tmp $msg $tmp_data_dir
+ trap - EXIT
+ exit $rc
+}
+
set -e
ASSUME_YES=
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 4, 11:31 AM (5 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29240668
Default Alt Text
D47289.id145473.diff (4 KB)
Attached To
Mode
D47289: git-arc: Trap on every mktemp
Attached
Detach File
Event Timeline
Log In to Comment