Module gitforge::lab[][src]

Expand description

GitLab client, talking to one GitLab instance

Limitations

Anonymous access is typically not supported. You will need to use a token.

Tokens

The token is a Personal access token, as can be created via the web UI:

  • Top right user icon menu: Preferences
  • Left sidebar: Access tokens (an oval icon with dots in)

Terminology and model - supplementary

  • Repository: a GitLab project. Identified by the string USER/PROJECT or GROUP/PROJECT.

  • User: a GitLab user or organisation or perhaps group. Identified by the user or organisation slug.

Example

use gitforge::forge;

let mut f = match (forge::Config {
  kind: "gitlab".parse().ok(),
  host: "salsa.debian.org".into(),
  ..Default::default()
}
  .load_default_token().unwrap()
  .forge()
){
  Err(forge::Error::TokenAlwaysRequired(_)) => {
    eprintln!("token not supplied, not running gitlab client test");
    return;
  },
  other => other.unwrap(),
};

let req = forge::Req::MergeRequests(forge::Req_MergeRequests{
  target_repo: "dgit-team/dgit-test-dummy".into(),
  statuses: Some([forge::IssueMrStatus::Open].iter().cloned().collect()),
  ..Default::default()
});

match f.request(&req).unwrap() {
  forge::Resp::MergeRequests { mrs,.. } => {
    for mr in mrs {
      println!("{:?}", &mr);
    }
  },
  x => panic!("unexpected response {:?}", &x),
};

Structs

GitLab client, as Forge. Use Box<dyn Forge> instead.