GitRemote

GitRemote

new GitRemote()

Interact with Git remote

Source:

Methods

(async) commitsUnknown(casefile) → {Promise.<(Array.<string>|false)>}

Test if a casefile references commits unknown to this remote

Source:

This method can be used prior to .share to determine whether the shared casefile will reference unknown commits. If the call to this method returns an Array (i.e. not false), three options can be offerred to the user: cancel the sharing of the casefile, push the unknown commits (possibly to refs/collaboration/referenced-commits/<COMMIT-HASH>) prior to sharing the casefile, or sharing the casefile despite the missing referent commits. A function implementing this logic would look like:

async function prepareSharing(remote, casefile, { userSelectedAction }) {
  const unshared = remote.commitsUnknown(casefile);
  if (unshared) {
    // Let the user decide action
    switch (userSelectedAction(unshared)) {
      case 'shareWithoutPush':
        return true;
      case 'cancel':
        return false;
      case 'pushAndShare':
        await remote.pushCommitRefs(...unshared);
        return true;
    }
  }
  return true;
}

The function above resolves true if the casefile should be shared (with remote.share(casefile)) and false if not.

This method only functions properly on a Casefile whose bookmarks embody the Bookmark type, specifically with regard to peg.commit and children.

Parameters:
Name Type Description
casefile Casefile

Casefile with bookmarks to check against this remote

Returns:

Either false (if this remote knows all referenced commits) or an Array of the commits that are unknown; this result is "truthy" if commits are unknown and false if all are known

Type
Promise.<(Array.<string>|false)>

delete(…casefiles) → {Promise.<null>}

Source:
Parameters:
Name Type Attributes Description
casefiles string | Casefile <repeatable>

Casefiles — or full paths to casefiles — to delete from this remote

Returns:
Type
Promise.<null>

fetchSharedCasefiles() → {Promise.<null>}

Fetch the casefiles from this remote to the local repository

Source:
Returns:
Type
Promise.<null>

(async) pushCommitRefs(…commits) → {Promise.<null>}

Push some commits to unique names in this remote

Source:

This method gets all of commits to this remote, allowing bookmarks to reference the commits even if they are not present in any other history shared with the remote.

This method should be used with care — and always in response to a user prompt — since it could result in uploading significant history to this remote.

Parameters:
Name Type Attributes Description
commits string <repeatable>
Returns:
Type
Promise.<null>

share(casefile) → {Promise.<{message: string, commit: ?string}>}

Share a Casefile to this remote

Source:
Parameters:
Name Type Description
casefile Casefile
Returns:
Type
Promise.<{message: string, commit: ?string}>