Skip to content

Commit 25fe12e

Browse files
Add documentation comments for commit_and_push() function
1 parent 9a068bc commit 25fe12e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/git.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ pub fn add_crate(app: &App, krate: &Crate) -> CargoResult<()> {
7777
/// file, deserlialise the crate from JSON, change the yank boolean to
7878
/// `true` or `false`, write all the lines back out, and commit and
7979
/// push the changes.
80-
// TODO: factor out the tasks this function does into smaller, separate
81-
// functions.
8280
pub fn yank(app: &App, krate: &str, version: &semver::Version, yanked: bool) -> CargoResult<()> {
8381
let repo = app.git_repo.lock().unwrap();
8482
let repo_path = repo.workdir().unwrap();
@@ -118,6 +116,21 @@ pub fn yank(app: &App, krate: &str, version: &semver::Version, yanked: bool) ->
118116
})
119117
}
120118

119+
/// Commits and pushes to the crates.io index.
120+
///
121+
/// There are currently 2 instances of the crates.io backend running
122+
/// on Heroku, and they race against each other e.g. if 2 pushes occur,
123+
/// then one will succeed while the other will need to be rebased before
124+
/// being pushed.
125+
///
126+
/// A maximum of 20 attempts to commit and push to the index currently
127+
/// accounts for the amount of traffic publishing crates, though this will
128+
/// eventually need to be changed past a certain point.
129+
///
130+
/// Notes:
131+
/// Currently, this function is called from the HTTP thread and is blocking.
132+
/// This could be changed to run from a different thread and use a callback
133+
/// upon completion to the HTTP thread.
121134
fn commit_and_push<F>(repo: &git2::Repository, mut f: F) -> CargoResult<()>
122135
where
123136
F: FnMut() -> CargoResult<(String, PathBuf)>,

0 commit comments

Comments
 (0)