fix(cli,ci): keep --source value in flagsFirst and use GIT_ASKPASS for GitCode push
This commit is contained in:
1 parent
f85e1aba88
commit
172df5c4d5
3 files changed
+24
-10
No files matched your search
@@ -252,8 +252,7 @@ jobs:
|
||||
}
|
||||
$tag = "runtime-$($env:RELEASE_ID)"
|
||||
git fetch --tags origin
|
||||
$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("Nwflower:$($env:GITCODE_TOKEN)"))
|
||||
git -c "http.extraheader=Authorization: Basic $auth" push "https://gitcode.com/Nwflower/Reims-Go.git" "refs/tags/${tag}:refs/tags/${tag}"
|
||||
git -c credential.helper= push "https://Nwflower:$($env:GITCODE_TOKEN)@gitcode.com/Nwflower/Reims-Go.git" "refs/tags/${tag}:refs/tags/${tag}"
|
||||
python scripts/sync-gitcode-release.py $tag
|
||||
|
||||
- name: Prune old alpha prereleases
|
||||
|
||||
@@ -41,10 +41,19 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
git fetch --tags origin
|
||||
# Configure token via extraheader so it never appears in remote URLs/logs.
|
||||
auth="$(printf '%s:%s' "$GITCODE_USER" "$GITCODE_TOKEN" | base64 -w0)"
|
||||
git -c "http.extraheader=Authorization: Basic $auth" push "https://gitcode.com/${GITCODE_REPO}.git" HEAD:refs/heads/main
|
||||
git -c "http.extraheader=Authorization: Basic $auth" push "https://gitcode.com/${GITCODE_REPO}.git" --tags
|
||||
# Use GIT_ASKPASS so the token never appears in URLs or process argv.
|
||||
askpass="$(mktemp)"
|
||||
chmod 700 "$askpass"
|
||||
cat > "$askpass" <<'EOF'
|
||||
#!/bin/sh
|
||||
case "$1" in
|
||||
*Username*) printf '%s\n' "$GITCODE_USER" ;;
|
||||
*) printf '%s\n' "$GITCODE_TOKEN" ;;
|
||||
esac
|
||||
EOF
|
||||
trap 'rm -f "$askpass"' EXIT
|
||||
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="$askpass" git -c credential.helper= push "https://gitcode.com/${GITCODE_REPO}.git" HEAD:refs/heads/main
|
||||
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="$askpass" git -c credential.helper= push "https://gitcode.com/${GITCODE_REPO}.git" --tags
|
||||
|
||||
- name: Sync Release and assets to GitCode
|
||||
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.sync_releases)
|
||||
|
||||
@@ -108,14 +108,20 @@ func alphaFlag(fs *flag.FlagSet, cfg *config.Config, usage string) *bool {
|
||||
return v
|
||||
}
|
||||
|
||||
// flagsFirst moves "-x" arguments before positional ones, so
|
||||
// "fetch latest --alpha" works like "fetch --alpha latest" (the flag
|
||||
// package stops at the first positional argument).
|
||||
// flagsFirst moves "-x" arguments (and their values for value flags like
|
||||
// --source) before positional ones, so "fetch latest --source gitcode --alpha"
|
||||
// works like "fetch --source gitcode --alpha latest" (the flag package stops
|
||||
// at the first positional argument).
|
||||
func flagsFirst(args []string) []string {
|
||||
var flags, rest []string
|
||||
for _, a := range args {
|
||||
for i := 0; i < len(args); i++ {
|
||||
a := args[i]
|
||||
if len(a) > 1 && a[0] == '-' {
|
||||
flags = append(flags, a)
|
||||
if (a == "-source" || a == "--source") && i+1 < len(args) {
|
||||
i++
|
||||
flags = append(flags, args[i])
|
||||
}
|
||||
} else {
|
||||
rest = append(rest, a)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user