17
.github/workflows/job_sync.yml
vendored
17
.github/workflows/job_sync.yml
vendored
@@ -13,48 +13,45 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sync:
|
sync:
|
||||||
if: env.GITHUB_ACTION == 0
|
if: github.server_url != 'https://github.com'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: init
|
- name: init
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "vtolstov <vtolstov@users.noreply.github.com>"
|
git config --global user.email "vtolstov <vtolstov@users.noreply.github.com>"
|
||||||
git config --global user.name "github-actions[bot]"
|
git config --global user.name "github-actions[bot]"
|
||||||
echo "machine git.unistack.org login vtolstov password ${{ secrets.TOKEN_GITEA }}" | tee -a /root/.netrc
|
echo "machine git.unistack.org login vtolstov password ${{ secrets.TOKEN_GITEA }}" >> /root/.netrc
|
||||||
echo "machine github.com login vtolstov password ${{ secrets.TOKEN_GITHUB }}" | tee -a /root/.netrc
|
echo "machine github.com login vtolstov password ${{ secrets.TOKEN_GITHUB }}" >> /root/.netrc
|
||||||
|
|
||||||
- name: sync master
|
- name: sync master
|
||||||
run: |
|
run: |
|
||||||
git clone --depth=10 --branch master --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
git clone --filter=blob:none --filter=tree:0 --branch master --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
||||||
cd repo
|
cd repo
|
||||||
git remote add --no-tags --fetch --track master upstream https://github.com/${GITHUB_REPOSITORY}
|
git remote add --no-tags --track master upstream https://github.com/${GITHUB_REPOSITORY}
|
||||||
git pull --rebase upstream master
|
git pull --rebase upstream master
|
||||||
git push upstream master --progress
|
git push upstream master --progress
|
||||||
git merge --allow-unrelated-histories "upstream/master"
|
|
||||||
git push origin master --progress
|
git push origin master --progress
|
||||||
cd ../
|
cd ../
|
||||||
rm -rf repo
|
rm -rf repo
|
||||||
|
|
||||||
- name: sync v3
|
- name: sync v3
|
||||||
run: |
|
run: |
|
||||||
git clone --depth=10 --branch v3 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
git clone --filter=blob:none --filter=tree:0 --branch v3 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
||||||
cd repo
|
cd repo
|
||||||
git remote add --no-tags --fetch --track v3 upstream https://github.com/${GITHUB_REPOSITORY}
|
git remote add --no-tags --fetch --track v3 upstream https://github.com/${GITHUB_REPOSITORY}
|
||||||
git pull --rebase upstream v3
|
git pull --rebase upstream v3
|
||||||
git push upstream v3
|
git push upstream v3
|
||||||
git merge --allow-unrelated-histories "upstream/v3"
|
|
||||||
git push origin v3 --progress
|
git push origin v3 --progress
|
||||||
cd ../
|
cd ../
|
||||||
rm -rf repo
|
rm -rf repo
|
||||||
|
|
||||||
- name: sync v4
|
- name: sync v4
|
||||||
run: |
|
run: |
|
||||||
git clone --depth=10 --branch v4 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
git clone --filter=blob:none --filter=tree:0 --branch v4 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
||||||
cd repo
|
cd repo
|
||||||
git remote add --no-tags --fetch --track v4 upstream https://github.com/${GITHUB_REPOSITORY}
|
git remote add --no-tags --fetch --track v4 upstream https://github.com/${GITHUB_REPOSITORY}
|
||||||
git pull --rebase upstream v4
|
git pull --rebase upstream v4
|
||||||
git push upstream v4
|
git push upstream v4
|
||||||
git merge --allow-unrelated-histories "upstream/v4"
|
|
||||||
git push origin v4 --progress
|
git push origin v4 --progress
|
||||||
cd ../
|
cd ../
|
||||||
rm -rf repo
|
rm -rf repo
|
||||||
|
|||||||
@@ -106,16 +106,7 @@ func (md Metadata) CopyTo(out Metadata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get obtains the values for a given key.
|
// Get obtains the values for a given key.
|
||||||
func (md Metadata) MustGet(k string) []string {
|
func (md Metadata) Get(k string) []string {
|
||||||
v, ok := md.Get(k)
|
|
||||||
if !ok {
|
|
||||||
panic("missing metadata key")
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get obtains the values for a given key.
|
|
||||||
func (md Metadata) Get(k string) ([]string, bool) {
|
|
||||||
v, ok := md[k]
|
v, ok := md[k]
|
||||||
if !ok {
|
if !ok {
|
||||||
v, ok = md[strings.ToLower(k)]
|
v, ok = md[strings.ToLower(k)]
|
||||||
@@ -123,27 +114,13 @@ func (md Metadata) Get(k string) ([]string, bool) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
v, ok = md[textproto.CanonicalMIMEHeaderKey(k)]
|
v, ok = md[textproto.CanonicalMIMEHeaderKey(k)]
|
||||||
}
|
}
|
||||||
return v, ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// MustGetJoined obtains the values for a given key
|
|
||||||
// with joined values with "," symbol
|
|
||||||
func (md Metadata) MustGetJoined(k string) string {
|
|
||||||
v, ok := md.GetJoined(k)
|
|
||||||
if !ok {
|
|
||||||
panic("missing metadata key")
|
|
||||||
}
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetJoined obtains the values for a given key
|
// GetJoined obtains the values for a given key
|
||||||
// with joined values with "," symbol
|
// with joined values with "," symbol
|
||||||
func (md Metadata) GetJoined(k string) (string, bool) {
|
func (md Metadata) GetJoined(k string) string {
|
||||||
v, ok := md.Get(k)
|
return strings.Join(md.Get(k), ",")
|
||||||
if !ok {
|
|
||||||
return "", ok
|
|
||||||
}
|
|
||||||
return strings.Join(v, ","), true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set sets the value of a given key with a slice of values.
|
// Set sets the value of a given key with a slice of values.
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ func TestAppendOutgoingContextModify(t *testing.T) {
|
|||||||
func TestLowercase(t *testing.T) {
|
func TestLowercase(t *testing.T) {
|
||||||
md := New(1)
|
md := New(1)
|
||||||
md["x-request-id"] = []string{"12345"}
|
md["x-request-id"] = []string{"12345"}
|
||||||
v, ok := md.GetJoined("X-Request-Id")
|
v := md.GetJoined("X-Request-Id")
|
||||||
if !ok || v == "" {
|
if v == "" {
|
||||||
t.Fatalf("metadata invalid %#+v", md)
|
t.Fatalf("metadata invalid %#+v", md)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,10 +51,10 @@ func TestMetadataSetMultiple(t *testing.T) {
|
|||||||
md := New(4)
|
md := New(4)
|
||||||
md.Set("key1", "val1", "key2", "val2")
|
md.Set("key1", "val1", "key2", "val2")
|
||||||
|
|
||||||
if v, ok := md.GetJoined("key1"); !ok || v != "val1" {
|
if v := md.GetJoined("key1"); v != "val1" {
|
||||||
t.Fatalf("invalid kv %#+v", md)
|
t.Fatalf("invalid kv %#+v", md)
|
||||||
}
|
}
|
||||||
if v, ok := md.GetJoined("key2"); !ok || v != "val2" {
|
if v := md.GetJoined("key2"); v != "val2" {
|
||||||
t.Fatalf("invalid kv %#+v", md)
|
t.Fatalf("invalid kv %#+v", md)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,14 +66,14 @@ func TestAppend(t *testing.T) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("metadata empty")
|
t.Fatal("metadata empty")
|
||||||
}
|
}
|
||||||
if _, ok := md.Get("key1"); !ok {
|
if v := md.Get("key1"); v == nil {
|
||||||
t.Fatal("key1 not found")
|
t.Fatal("key1 not found")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPairs(t *testing.T) {
|
func TestPairs(t *testing.T) {
|
||||||
md := Pairs("key1", "val1", "key2", "val2")
|
md := Pairs("key1", "val1", "key2", "val2")
|
||||||
if _, ok := md.Get("key1"); !ok {
|
if v := md.Get("key1"); v == nil {
|
||||||
t.Fatal("key1 not found")
|
t.Fatal("key1 not found")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ func TestPassing(t *testing.T) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("missing metadata from outgoing context")
|
t.Fatalf("missing metadata from outgoing context")
|
||||||
}
|
}
|
||||||
if v, ok := md.Get("Key1"); !ok || v[0] != "Val1" {
|
if v := md.Get("Key1"); v == nil || v[0] != "Val1" {
|
||||||
t.Fatalf("invalid metadata value %#+v", md)
|
t.Fatalf("invalid metadata value %#+v", md)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,21 +127,21 @@ func TestIterator(t *testing.T) {
|
|||||||
func TestMedataCanonicalKey(t *testing.T) {
|
func TestMedataCanonicalKey(t *testing.T) {
|
||||||
md := New(1)
|
md := New(1)
|
||||||
md.Set("x-request-id", "12345")
|
md.Set("x-request-id", "12345")
|
||||||
v, ok := md.GetJoined("x-request-id")
|
v := md.GetJoined("x-request-id")
|
||||||
if !ok {
|
if v == "" {
|
||||||
t.Fatalf("failed to get x-request-id")
|
t.Fatalf("failed to get x-request-id")
|
||||||
} else if v != "12345" {
|
} else if v != "12345" {
|
||||||
t.Fatalf("invalid metadata value: %s != %s", "12345", v)
|
t.Fatalf("invalid metadata value: %s != %s", "12345", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
v, ok = md.GetJoined("X-Request-Id")
|
v = md.GetJoined("X-Request-Id")
|
||||||
if !ok {
|
if v == "" {
|
||||||
t.Fatalf("failed to get x-request-id")
|
t.Fatalf("failed to get x-request-id")
|
||||||
} else if v != "12345" {
|
} else if v != "12345" {
|
||||||
t.Fatalf("invalid metadata value: %s != %s", "12345", v)
|
t.Fatalf("invalid metadata value: %s != %s", "12345", v)
|
||||||
}
|
}
|
||||||
v, ok = md.GetJoined("X-Request-ID")
|
v = md.GetJoined("X-Request-ID")
|
||||||
if !ok {
|
if v == "" {
|
||||||
t.Fatalf("failed to get x-request-id")
|
t.Fatalf("failed to get x-request-id")
|
||||||
} else if v != "12345" {
|
} else if v != "12345" {
|
||||||
t.Fatalf("invalid metadata value: %s != %s", "12345", v)
|
t.Fatalf("invalid metadata value: %s != %s", "12345", v)
|
||||||
@@ -153,8 +153,8 @@ func TestMetadataSet(t *testing.T) {
|
|||||||
|
|
||||||
md.Set("Key", "val")
|
md.Set("Key", "val")
|
||||||
|
|
||||||
val, ok := md.GetJoined("Key")
|
val := md.GetJoined("Key")
|
||||||
if !ok {
|
if val == "" {
|
||||||
t.Fatal("key Key not found")
|
t.Fatal("key Key not found")
|
||||||
}
|
}
|
||||||
if val != "val" {
|
if val != "val" {
|
||||||
@@ -169,8 +169,8 @@ func TestMetadataDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
md.Del("Baz")
|
md.Del("Baz")
|
||||||
_, ok := md.Get("Baz")
|
v := md.Get("Baz")
|
||||||
if ok {
|
if v != nil {
|
||||||
t.Fatal("key Baz not deleted")
|
t.Fatal("key Baz not deleted")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ func TestAppendIncomingContext(t *testing.T) {
|
|||||||
if nmd == nil || !ok {
|
if nmd == nil || !ok {
|
||||||
t.Fatal("AppendIncomingContext not works")
|
t.Fatal("AppendIncomingContext not works")
|
||||||
}
|
}
|
||||||
if v, ok := nmd.GetJoined("key2"); !ok || v != "val2" {
|
if v := nmd.GetJoined("key2"); v != "val2" {
|
||||||
t.Fatal("AppendIncomingContext not works")
|
t.Fatal("AppendIncomingContext not works")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,7 @@ func TestAppendOutgoingContext(t *testing.T) {
|
|||||||
if nmd == nil || !ok {
|
if nmd == nil || !ok {
|
||||||
t.Fatal("AppendOutgoingContext not works")
|
t.Fatal("AppendOutgoingContext not works")
|
||||||
}
|
}
|
||||||
if v, ok := nmd.GetJoined("key2"); !ok || v != "val2" {
|
if v := nmd.GetJoined("key2"); v != "val2" {
|
||||||
t.Fatal("AppendOutgoingContext not works")
|
t.Fatal("AppendOutgoingContext not works")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user