Skip to content

Commit 126b1de

Browse files
Add Repository::getSymbolicRefTarget and Repository::getRemoteHead
1 parent 70b2eb3 commit 126b1de

17 files changed

Lines changed: 117 additions & 3 deletions

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ Get the target of the given reference.
202202

203203
Returns the string target of the given reference.
204204

205+
### Repository.getRemoteHead([remoteName])
206+
207+
Get the branch that a remote's `HEAD` points to — i.e., the remote's default
208+
branch. This is the equivalent of `git symbolic-ref refs/remotes/<remoteName>/HEAD`.
209+
210+
`remoteName` - The string name of the remote (default: `origin`).
211+
212+
Returns the string reference name (e.g. `refs/remotes/origin/master`), or
213+
`null` if the remote has no `HEAD` reference.
214+
205215
### Repository.getShortHead()
206216

207217
Get a possibly shortened version of value returns by `getHead()`. This will
@@ -220,6 +230,16 @@ include ignored paths.
220230
Returns an integer status number if a path is specified and returns an object
221231
with path keys and integer status values if no path is specified.
222232

233+
### Repository.getSymbolicRefTarget(ref)
234+
235+
Get the name of the reference that a symbolic reference points to, without
236+
resolving it any further. This is the equivalent of `git symbolic-ref <ref>`.
237+
238+
`ref` - The string reference.
239+
240+
Returns the string name of the reference that `ref` points to, or `null` if
241+
`ref` does not exist or is not a symbolic reference.
242+
223243
### Repository.getUpstreamBranch([branch])
224244

225245
Get the upstream branch of the given branch.

spec/fixtures/develop.git/HEAD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/develop

spec/fixtures/develop.git/config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = true
4+
bare = false
5+
logallrefupdates = true
6+
ignorecase = true
7+
[branch "develop"]
8+
remote = origin
9+
merge = refs/heads/develop

spec/fixtures/develop.git/index

137 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
xK��OR02fH�,*.Q���K�*NM��K���A
2+
m
Binary file not shown.
Binary file not shown.

spec/fixtures/develop.git/objects/41/d3f5ab722c21457592142598d5d1e749927e61

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xm�Mj�0���)��<�!�r�\`l��@meL{��d۷x���\��n#~XU���<'��! L#INQCO��r����6�� 4 O��c��}�c�I5�46����n��UGk~�?Y�=�e9A���؅����{�h;fZ�kMU�o���vۧ��hz�ê�O�{�\��*��LF�

spec/fixtures/develop.git/objects/85/ba7b41e728f2347f0209305eed5874444547a4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
xm�Q
2+
�0D��)rK�vI"<�H�-���-z|�����<�7Xr�Y[�D����<�4&�� �J�[@��BRq�G��F/�'�����K>��:���h�1J�1U}Y�Jo}�ֲ��>�c���i��B�G��\��gR_�J9�

0 commit comments

Comments
 (0)