团队作业8——第二次项目冲刺(Beta阶段)5.25

1、当天站立式会议照片

会议内容:

本次会议为第六次会议
本次会议在陆大楼3楼召开,本次会议内容:
①:检查总结上次任务完成情况
②:安排今天的分工
③:对昨天的问题进行讨论
④:遇到困难,及时群里反馈

2. 每个人的工作 (有work item 的ID)

工作中遇到的困难:

随着beta计划的进行,到现在已经六天了,渐渐的我们的项目越来越完善,同时也会遇到很多困难,但是我们每天都会召开团队会议,对前一天遇到的问题进行讨论并想方法解决,马上beta计划就也要结束了,相信我们会成功发布项目。

3. 发布项目燃尽图;请用专业的工具完成


横坐标:工作日,以天为单位,一共七天,代表着beta冲刺阶段的时间一共为7天
纵坐标:剩余卡片数,以卡片数为单位,代表着每一个任务。
黄线:代表设置的卡片数在规定的工作日内的理想的完成情况。
蓝线:表示我们实际完成的卡片数。

4. 代码签入记录:

https://coding.net/u/hts-technology/p/CodeManagement/git/tree/master

部分代码:

/**
	 * 打开远程仓库
	 * 
	 * @param repositoryPath
	 * @return
	 */
	public static Repository openRepository(String repositoryPath) {
		Repository repository = null;
		try {
			Git git = Git.open(new File(repositoryPath));
			repository = git.getRepository();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} // 將本地倉庫打開
		return repository;
	}

	/**
	 * git pull
	 * 
	 * @param repositoryPath
	 */
	public static Repository pullFromRemoteRepository(Git git) {
		try {
			git.pull().call();
		} catch (GitAPIException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return git.getRepository();
	}

	/**
	 * 統計給定commitID后所有commit信息
	 * 
	 */
	public static void diffBetweenCommit(String repositoryPath, String lastcommitId) {
		Git git;
		Repository repository;
		try {
			git = Git.open(new File(repositoryPath));
			repository = pullFromRemoteRepository(git);
			RevWalk walk = new RevWalk(repository);
			Ref head = repository.findRef("HEAD");
			List<RevCommit> commitList = new ArrayList<>();
			Iterable<RevCommit> commits;
			try {
				commits = git.log().all().call();
				for (RevCommit commit : commits) {
					commitList.add(commit);
				}
				int numCommit = commitList.size();

				// 获取上一次的commit在list中的位置
				int fromIdToWirte = 0;
				for (int i = numCommit - 1; i > 0; i--) {
					if (commitList.get(i).getId().getName().equals(lastcommitId)) {
						fromIdToWirte = i;
						break;
					}
				}

				for (int i = fromIdToWirte; i > 0; i--) {

					// 得到commit的时间
					long sec = commitList.get(i).getCommitTime() * 1000;
					Date dat = new Date(sec);
					GregorianCalendar gc = new GregorianCalendar();
					gc.setTime(dat);
					java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
					String newCommitTime = format.format(gc.getTime());
					
					// 得到两次commit的不同之处
					AbstractTreeIterator oldTree = prepareTreeParser(repository, commitList.get(i));
					AbstractTreeIterator newTree = prepareTreeParser(repository, commitList.get(i - 1));
					List<DiffEntry> diff = git.diff().setOldTree(oldTree).setNewTree(newTree)
							.setShowNameAndStatusOnly(true).call();

					// 格式化输出格式
					ByteArrayOutputStream out = new ByteArrayOutputStream();
					DiffFormatter df = new DiffFormatter(out);
					df.setDiffComparator(RawTextComparator.WS_IGNORE_ALL);// 设置比较器为忽略空白字符对比(Ignores
																			// all
																			// whitespace)

					df.setRepository(git.getRepository());

					//统计newCommit与OldCommit新增了多少行,减少了多少行
					for (DiffEntry diffEntry : diff) {
						
						// 获取文件差异位置,从而统计差异的行数,如增加行数,减少行数
						FileHeader fileHeader;
						fileHeader = df.toFileHeader(diffEntry);
						List<HunkHeader> hunks = (List<HunkHeader>) fileHeader.getHunks();
						int addSize = 0;
						int subSize = 0;
						for (HunkHeader hunkHeader : hunks) {
							EditList editList = hunkHeader.toEditList();
							for (Edit edit : editList) {
								subSize += edit.getEndA() - edit.getBeginA();
								addSize += edit.getEndB() - edit.getBeginB();
							}
						}
						out.reset();
					}

				}
			} catch (GitAPIException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public static AbstractTreeIterator prepareTreeParser(Repository repository, RevCommit commit) throws IOException {
		System.out.println(commit.getId());
		try (RevWalk walk = new RevWalk(repository)) {
			System.out.println(commit.getTree().getId());
			RevTree tree = walk.parseTree(commit.getTree().getId());
			CanonicalTreeParser oldTreeParser = new CanonicalTreeParser();
			try (ObjectReader oldReader = repository.newObjectReader()) {
				oldTreeParser.reset(oldReader, tree.getId());
			}
			walk.dispose();
			return oldTreeParser;
		} catch (Exception e) {

		}
		return null;
	}
posted @ 2017-05-25 18:54  NO.NE  阅读(237)  评论(4编辑  收藏  举报