MCPcopy Create free account
hub / github.com/libgit2/pygit2 / set_symbolic_target

Method set_symbolic_target

pygit2/transaction.py:126–155  ·  view source on GitHub ↗

Set the target of a symbolic reference. The reference must be locked first via lock_ref(). Args: refname: Name of the reference to update target: Target reference name (e.g., 'refs/heads/master') signature: Signature for the reflog (None to use r

(
        self,
        refname: str,
        target: str,
        signature: Signature | None = None,
        message: str | None = None,
    )

Source from the content-addressed store, hash-verified

124 check_error(err)
125
126 def set_symbolic_target(
127 self,
128 refname: str,
129 target: str,
130 signature: Signature | None = None,
131 message: str | None = None,
132 ) -> None:
133 """Set the target of a symbolic reference.
134
135 The reference must be locked first via lock_ref().
136
137 Args:
138 refname: Name of the reference to update
139 target: Target reference name (e.g., 'refs/heads/master')
140 signature: Signature for the reflog (None to use repo identity)
141 message: Message for the reflog
142 """
143 self._check_thread()
144 if self._tx is None:
145 raise ValueError('Transaction already closed')
146
147 c_refname = ffi.new('char[]', to_bytes(refname))
148 c_target = ffi.new('char[]', to_bytes(target))
149 c_sig = signature._pointer if signature else ffi.NULL
150 c_msg = ffi.new('char[]', to_bytes(message)) if message else ffi.NULL
151
152 err = C.git_transaction_set_symbolic_target(
153 self._tx, c_refname, c_target, c_sig, c_msg
154 )
155 check_error(err)
156
157 def remove(self, refname: str) -> None:
158 """Remove a reference.

Callers 1

Calls 3

_check_threadMethod · 0.95
to_bytesFunction · 0.85
check_errorFunction · 0.85

Tested by 1