Skip to content

Commit ef1b9ce

Browse files
Skip changes without id in stacked push
Instead of rejecting the whole push
1 parent 0278577 commit ef1b9ce

File tree

4 files changed

+37
-33
lines changed

4 files changed

+37
-33
lines changed

josh-core/src/changes.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ pub fn changes_to_refs(
130130
change.commit
131131
)));
132132
}
133-
} else {
134-
return Err(josh_error(&format!(
135-
"rejecting to push {:?} without id",
136-
change.commit
137-
)));
133+
seen.insert(id);
138134
}
139135
}
140136

tests/proxy/push_stacked.t

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
$ git commit -m "add file3" 1> /dev/null
5757
$ git push -o author=josh@example.com origin master:refs/stack/for/master
5858
remote: josh-proxy: pre-receive hook
59-
remote: upstream: response status: 500 Internal Server Error
59+
remote: upstream: response status: 200 OK
6060
remote: upstream: response body:
6161
remote:
62-
remote: rejecting to push 3ad32b3bd3bb778441e7eae43930d8dc6293eddc without id
63-
remote: error: hook declined to update refs/stack/for/master
62+
remote: Everything up-to-date
63+
remote: Everything up-to-date
64+
remote: To http://localhost:8001/real_repo.git
65+
remote: ec41aad..3ad32b3 master -> @heads/master/josh@example.com
6466
To http://localhost:8002/real_repo.git
65-
! [remote rejected] master -> refs/stack/for/master (hook declined)
66-
error: failed to push some refs to 'http://localhost:8002/real_repo.git'
67-
[1]
67+
* [new reference] master -> refs/stack/for/master
6868
$ git push -o author=foo@example.com origin master:refs/stack/for/master
6969
remote: josh-proxy: pre-receive hook
7070
remote: upstream: response status: 200 OK
@@ -85,8 +85,8 @@
8585
* [new branch] @heads/master/josh@example.com -> origin/@heads/master/josh@example.com
8686

8787
$ git log --decorate --graph --pretty="%s %d"
88-
* add file3 (HEAD -> master, origin/@heads/master/foo@example.com)
89-
* Change-Id: foo7 (origin/@heads/master/josh@example.com, origin/@changes/master/josh@example.com/foo7)
88+
* add file3 (HEAD -> master, origin/@heads/master/josh@example.com, origin/@heads/master/foo@example.com)
89+
* Change-Id: foo7 (origin/@changes/master/josh@example.com/foo7)
9090
* Change-Id: 1234 (origin/@changes/master/josh@example.com/1234)
9191
* add file1 (origin/master, origin/HEAD)
9292

@@ -119,7 +119,7 @@ get listed if they differ from HEAD
119119
3b0e3dbefd779ec54d92286047f32d3129161c0d\trefs/heads/@changes/master/josh@example.com/1234 (esc)
120120
ec41aad70b4b898baf48efeb795a7753d9674152\trefs/heads/@changes/master/josh@example.com/foo7 (esc)
121121
3ad32b3bd3bb778441e7eae43930d8dc6293eddc\trefs/heads/@heads/master/foo@example.com (esc)
122-
ec41aad70b4b898baf48efeb795a7753d9674152\trefs/heads/@heads/master/josh@example.com (esc)
122+
3ad32b3bd3bb778441e7eae43930d8dc6293eddc\trefs/heads/@heads/master/josh@example.com (esc)
123123
4950fa502f51b7bfda0d7975dbff9b0f9a9481ca\trefs/heads/master (esc)
124124

125125
$ git ls-remote http://localhost:8002/real_repo.git:/sub1.git

tests/proxy/push_stacked_gerrit.t

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@
6363
$ git commit -m "add file3" 1> /dev/null
6464
$ git push -o author=josh@example.com origin master:refs/for/master
6565
remote: josh-proxy: pre-receive hook
66-
remote: upstream: response status: 500 Internal Server Error
66+
remote: upstream: response status: 200 OK
6767
remote: upstream: response body:
6868
remote:
69-
remote: rejecting to push 3ad32b3bd3bb778441e7eae43930d8dc6293eddc without id
70-
remote: error: hook declined to update refs/for/master
69+
remote: Everything up-to-date
70+
remote: Everything up-to-date
71+
remote: To http://localhost:8001/real_repo.git
72+
remote: ec41aad..3ad32b3 JOSH_PUSH -> refs/for/master
73+
remote: To http://localhost:8001/real_repo.git
74+
remote: ec41aad..3ad32b3 master -> @heads/master/josh@example.com
7175
To http://localhost:8002/real_repo.git
72-
! [remote rejected] master -> refs/for/master (hook declined)
73-
error: failed to push some refs to 'http://localhost:8002/real_repo.git'
74-
[1]
76+
* [new reference] master -> refs/for/master
7577
$ git push http://localhost:8001/real_repo.git :refs/for/master
7678
To http://localhost:8001/real_repo.git
7779
- [deleted] refs/for/master
@@ -97,8 +99,8 @@
9799
* [new branch] @heads/master/josh@example.com -> origin/@heads/master/josh@example.com
98100

99101
$ git log --decorate --graph --pretty="%s %d"
100-
* add file3 (HEAD -> master, origin/@heads/master/foo@example.com)
101-
* Change-Id: foo7 (origin/@heads/master/josh@example.com, origin/@changes/master/josh@example.com/foo7)
102+
* add file3 (HEAD -> master, origin/@heads/master/josh@example.com, origin/@heads/master/foo@example.com)
103+
* Change-Id: foo7 (origin/@changes/master/josh@example.com/foo7)
102104
* Change-Id: 1234 (origin/@changes/master/josh@example.com/1234)
103105
* add file1 (origin/master, origin/HEAD)
104106

@@ -111,8 +113,8 @@
111113
* [new branch] @heads/master/josh@example.com -> origin/@heads/master/josh@example.com
112114
$ git checkout -q @heads/master/foo@example.com
113115
$ git log --decorate --graph --pretty="%s %d"
114-
* add file3 (HEAD -> @heads/master/foo@example.com, origin/@heads/master/foo@example.com)
115-
* Change-Id: foo7 (origin/@heads/master/josh@example.com, origin/@changes/master/josh@example.com/foo7)
116+
* add file3 (HEAD -> @heads/master/foo@example.com, origin/@heads/master/josh@example.com, origin/@heads/master/foo@example.com)
117+
* Change-Id: foo7 (origin/@changes/master/josh@example.com/foo7)
116118
* Change-Id: 1234 (origin/@changes/master/josh@example.com/1234)
117119
* add file1 (origin/master, origin/HEAD, master)
118120

tests/proxy/push_stacked_sub.t

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@
7373
$ git commit -m "add file3" 1> /dev/null
7474
$ git push -o author=josh@example.com origin master:refs/stack/for/master
7575
remote: josh-proxy: pre-receive hook
76-
remote: upstream: response status: 500 Internal Server Error
76+
remote: upstream: response status: 200 OK
7777
remote: upstream: response body:
7878
remote:
79-
remote: rejecting to push a3065162ecee0fecc977ec04a275e10b5e15a39c without id
80-
remote: error: hook declined to update refs/stack/for/master
79+
remote: Everything up-to-date
80+
remote: Everything up-to-date
81+
remote: To http://localhost:8001/real_repo.git
82+
remote: 2bb9471..a306516 master -> @heads/master/josh@example.com
8183
To http://localhost:8002/real_repo.git:/sub1.git
82-
! [remote rejected] master -> refs/stack/for/master (hook declined)
83-
error: failed to push some refs to 'http://localhost:8002/real_repo.git:/sub1.git'
84-
[1]
84+
* [new reference] master -> refs/stack/for/master
8585

8686
$ curl -s http://localhost:8002/flush
8787
Flushed credential cache
@@ -94,8 +94,8 @@
9494
* [new branch] @heads/master/josh@example.com -> origin/@heads/master/josh@example.com
9595
* [new branch] @heads/other_branch/josh@example.com -> origin/@heads/other_branch/josh@example.com
9696
$ git log --decorate --graph --pretty="%s %d"
97-
* add file3 (HEAD -> master)
98-
* Change-Id: foo7 (origin/@heads/other_branch/josh@example.com, origin/@heads/master/josh@example.com, origin/@changes/other_branch/josh@example.com/foo7, origin/@changes/master/josh@example.com/foo7)
97+
* add file3 (HEAD -> master, origin/@heads/master/josh@example.com)
98+
* Change-Id: foo7 (origin/@heads/other_branch/josh@example.com, origin/@changes/other_branch/josh@example.com/foo7, origin/@changes/master/josh@example.com/foo7)
9999
* Change-Id: 1234 (origin/@changes/other_branch/josh@example.com/1234, origin/@changes/master/josh@example.com/1234)
100100
* add file1 (origin/master, origin/HEAD)
101101

@@ -151,15 +151,21 @@ Make sure all temporary namespace got removed
151151
| | | `-- 77ff51363c9825cc2a221fc0ba5a883a1a2c72
152152
| | |-- 6b
153153
| | | `-- 46faacade805991bcaea19382c9d941828ce80
154+
| | |-- 88
155+
| | | `-- 2b84c5d3241087bc41982a744b72b7a174c49e
154156
| | |-- a0
155157
| | | `-- 24003ee1acc6bf70318a46e7b6df651b9dc246
158+
| | |-- a3
159+
| | | `-- 065162ecee0fecc977ec04a275e10b5e15a39c
156160
| | |-- b2
157161
| | | `-- ea883bc5df63565960a38cad7a57f73ac66eaa
158162
| | |-- ba
159163
| | | |-- 7e17233d9f79c96cb694959eb065302acd96a6
160164
| | | `-- c8af20b53d712874a32944874c66a21afa91f9
161165
| | |-- bb
162166
| | | `-- 282e9cdc1b972fffd08fd21eead43bc0c83cb8
167+
| | |-- be
168+
| | | `-- 33ab805ad4ef7ddda5b51e4a78ec0fac6b699a
163169
| | |-- c6
164170
| | | `-- 27a2e3a6bfbb7307f522ad94fdfc8c20b92967
165171
| | |-- c8
@@ -233,7 +239,7 @@ Make sure all temporary namespace got removed
233239
|-- namespaces
234240
`-- tags
235241

236-
58 directories, 44 files
242+
61 directories, 47 files
237243

238244
$ cat ${TESTTMP}/josh-proxy.out
239245
$ cat ${TESTTMP}/josh-proxy.out | grep REPO_UPDATE

0 commit comments

Comments
 (0)