def test_repo_status(): path = os.path.join(TESTING_BASE_DIR, 'test-repo') repo = make_repo(path, ['testing']) out0 = dvcs.repo_status(repo, short=False) out1 = dvcs.repo_status(repo, short=True) cleanup_repo(path) assert out0 in STATUS_LONG assert out1 in STATUS_SHORT
def test_repo_status(tmpdir): path = str(tmpdir / 'test-repo') repo = make_repo(path, ['testing']) out0 = dvcs.repo_status(repo, short=False) out1 = dvcs.repo_status(repo, short=True) cleanup_repo(path) assert out0 in STATUS_LONG assert out1 in STATUS_SHORT
def clean(collection, remove): """TODO ddrimport cleanup subcommand docs """ start = datetime.now() # ensure we have absolute paths (CWD+relpath) collection_path = os.path.abspath(os.path.normpath(collection)) # Check args if not (os.path.isdir(collection_path)): print('ddrimport: collection path must be a directory.') sys.exit(1) if not os.path.exists(collection_path): print('ddrimport: Collection does not exist.') sys.exit(1) repo = dvcs.repository(collection) logging.debug('Resetting staged files') dvcs.reset(repo) logging.debug('Reverting modified files') dvcs.revert(repo) if remove: logging.debug('Removing untracked files') dvcs.remove_untracked(repo) status = dvcs.repo_status(repo) logging.debug('status\n%s' % status) finish = datetime.now() elapsed = finish - start logging.info('DONE - %s elapsed' % elapsed)
def status(collection_path, short=False): """Command-line function for running git status on collection repository. @param collection_path: Absolute path to collection repo. @return: message ('ok' if successful) """ return dvcs.repo_status(collection_path)
def status(collection, short=False): """Command-line function for running git status on collection repository. @param collection: Collection @return: message ('ok' if successful) """ return dvcs.repo_status(dvcs.repository(collection.path))
def repo_status(self): """Get status of collection repo vis-a-vis origin/master. The repo_(synced,ahead,behind,diverged,conflicted) functions all use the result of this function so that git-status is only called once. """ if not self._status and (os.path.exists(self.git_path)): status = dvcs.repo_status(dvcs.repository(self.path), short=True) if status: self._status = status return self._status
def repo_status( self ): """Get status of collection repo vis-a-vis origin/master. The repo_(synced,ahead,behind,diverged,conflicted) functions all use the result of this function so that git-status is only called once. """ if not self._status and (os.path.exists(os.path.join(self.path, '.git'))): status = dvcs.repo_status(self.path, short=True) if status: self._status = status return self._status
def update( base_dir, collection_path ): """Gets a bunch of status info for the collection; refreshes if forced timestamp, elapsed, status, annex_status, syncstatus @param force: Boolean Forces refresh of status @returns: dict """ start = datetime.now() repo = dvcs.repository(collection_path) status = dvcs.repo_status(repo, short=True) annex_status = dvcs.annex_status(repo) timestamp = datetime.now() syncstatus = sync_status(collection_path, git_status=status, timestamp=timestamp, force=True) elapsed = timestamp - start text = write(base_dir, collection_path, timestamp, elapsed, status, annex_status, syncstatus) return loads(text)